From 8474c99ee0f7a993bbd1d931b547d5e817faefd9 Mon Sep 17 00:00:00 2001 From: whzup <> Date: Tue, 5 May 2020 12:57:58 +0200 Subject: [PATCH] Fix unrendered math There were spaces in the inline math. In the documentation of the handlers there was a CR missing. --- .../usecases/electric_circuit_problem.ipynb | 16 ++++++++-------- pyswarms/backend/handlers.py | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/examples/usecases/electric_circuit_problem.ipynb b/docs/examples/usecases/electric_circuit_problem.ipynb index de7544b3..6c0fce1a 100644 --- a/docs/examples/usecases/electric_circuit_problem.ipynb +++ b/docs/examples/usecases/electric_circuit_problem.ipynb @@ -26,7 +26,7 @@ "\n", "Kirchhoff's voltage law states that the directed sum of the voltages around any closed loop is zero. In other words, the sum of the voltages of the passive elements must be equal to the sum of the voltages of the active elements, as expressed by the following equation:\n", "\n", - "$ U = v_D + v_R $, where $U$ represents the voltage of the source and, $v_D$ and $v_R$ represent the voltage of the diode and the resistor, respectively.\n", + "$U = v_D + v_R $, where $U$ represents the voltage of the source and, $v_D$ and $v_R$ represent the voltage of the diode and the resistor, respectively.\n", "\n", "To determine the current flowing through the circuit, $v_D$ and $v_R$ need to be defined as functions of $I$. A simplified Shockley equation will be used to formulate the current-voltage characteristic function of the diode. This function relates the current that flows through the diode with the voltage across it. Both $I_s$ and $v_T$ are known properties.\n", "\n", @@ -49,7 +49,7 @@ "\n", "And by replacing these expressions on the Kirschhoff's voltage law equation, the following equation is obtained:\n", "\n", - "$ U = v_T \\log{\\left |\\frac{I}{I_s}\\right |} + R I $\n" + "$U = v_T \\log{\\left |\\frac{I}{I_s}\\right |} + R I$\n" ] }, { @@ -68,15 +68,15 @@ "source": [ "### Known parameter values\n", "\n", - "The voltage of the source is $ 10 \\space V $ and the resistance of the resistor is $ 100 \\space \\Omega $. The diode is a silicon diode and it is assumed to be at room temperature.\n", + "The voltage of the source is $10 \\space V$ and the resistance of the resistor is $100 \\space \\Omega$. The diode is a silicon diode and it is assumed to be at room temperature.\n", "\n", - "$U = 10 \\space V $\n", + "$U = 10 \\space V$\n", "\n", - "$R = 100 \\space \\Omega $\n", + "$R = 100 \\space \\Omega$\n", "\n", "$I_s = 9.4 \\space pA = 9.4 \\times 10^{-12} \\space A$ (reverse bias saturation current of silicon diodes at room temperature, $T=300 \\space K$)\n", "\n", - "$v_T = 25.85 \\space mV = 25.85 \\times 10^{-3} \\space V $ (thermal voltage at room temperature, $T=300 \\space K$)" + "$v_T = 25.85 \\space mV = 25.85 \\times 10^{-3} \\space V$ (thermal voltage at room temperature, $T=300 \\space K$)" ] }, { @@ -231,7 +231,7 @@ "source": [ "### Checking the solution\n", "\n", - "The current flowing through the circuit is approximately $ 0.094 \\space A$ which yields a cost of almost zero. The graph below illustrates the relationship between the cost $c$ and the current $I$. As shown, the cost reaches its minimum value of zero when $I$ is somewhere close to $0.09$.\n", + "The current flowing through the circuit is approximately $0.094 \\space A$ which yields a cost of almost zero. The graph below illustrates the relationship between the cost $c$ and the current $I$. As shown, the cost reaches its minimum value of zero when $I$ is somewhere close to $0.09$.\n", "\n", "The use of ```reshape(100, 1)``` is required since ```np.linspace(0.001, 0.1, 100)``` returns an array with shape ```(100,)``` and first argument of the cost function must be a unidimensional array, that is, an array with shape ```(100, 1)```. " ] @@ -329,7 +329,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.8.2" } }, "nbformat": 4, diff --git a/pyswarms/backend/handlers.py b/pyswarms/backend/handlers.py index fab8d7df..19ccd9a1 100644 --- a/pyswarms/backend/handlers.py +++ b/pyswarms/backend/handlers.py @@ -467,6 +467,7 @@ def adjust(self, velocity, clamp=None, **kwargs): r"""Adjust the velocity to the new position The velocity is adjusted such that the following equation holds: + .. math:: \mathbf{v_{i,t}} = \mathbf{x_{i,t}} - \mathbf{x_{i,t-1}} @@ -498,6 +499,7 @@ def invert(self, velocity, clamp=None, **kwargs): kwarg :code:`z`. The default shrinking factor is :code:`0.5`. For all velocities whose particles are out of bounds the following equation is applied: + .. math:: \mathbf{v_{i,t}} = -z\mathbf{v_{i,t}}