Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unrendered math #399

Merged
merged 1 commit into from
May 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/examples/usecases/electric_circuit_problem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
]
},
{
Expand All @@ -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$)"
]
},
{
Expand Down Expand Up @@ -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)```. "
]
Expand Down Expand Up @@ -329,7 +329,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.8.2"
}
},
"nbformat": 4,
Expand Down
2 changes: 2 additions & 0 deletions pyswarms/backend/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}
Expand Down