Math

class pathsim.blocks.math.Math[source]

Bases: Block

Base math block.

Note

This block doesnt implement any functionality itself. Its intended to be used as a base for the elementary math blocks. Its not intended to be used directly!

update(t)[source]

update algebraic component of system equation

Parameters:

t (float) – evaluation time

class pathsim.blocks.math.Sin[source]

Bases: Math

Sine operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \sin(\vec{u})\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Cos[source]

Bases: Math

Cosine operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \cos(\vec{u})\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Sqrt[source]

Bases: Math

Square root operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \sqrt{|\vec{u}|}\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Abs[source]

Bases: Math

Absolute value operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \vert| \vec{u} \vert|\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Pow(exponent=2)[source]

Bases: Math

Raise to power operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \vec{u}^{p}\]
Parameters:

exponent (float, array_like) – exponent to raise the input to the power of

op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.PowProd(exponents=2)[source]

Bases: Math

Power-Product operator block.

This block raises each input to a power and then multiplies all results together:

\[y = \prod_i u_i^{p_i}\]
Parameters:

exponents (float, array_like) – exponent(s) to raise the inputs to the power of. If scalar, applies same exponent to all inputs.

op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Polynomial(coeffs=[1.0, 0.0])[source]

Bases: Math

Polynomial operator block.

Evaluates a polynomial in the input. The coefficients follow the numpy.polyval convention, with the highest order term first:

\[\vec{y} = c_0 \vec{u}^n + c_1 \vec{u}^{n-1} + \dots + c_{n-1} \vec{u} + c_n\]

This block supports vector inputs (the polynomial is evaluated element-wise).

Example

Quadratic \(y = 2 u^2 + 3 u + 1\):

p = Polynomial(coeffs=[2, 3, 1])
Parameters:

coeffs (array_like) – polynomial coefficients in descending order of power, following the numpy.polyval convention

op_alg

internal algebraic operator

Type:

Operator

property coeffs
set(**kwargs)

Set multiple parameters and reinitialize once.

Parameters:

kwargs (dict) – parameter names and their new values

Example

block.set(K=5.0, T=0.3)
class pathsim.blocks.math.Exp[source]

Bases: Math

Exponential operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = e^{\vec{u}}\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Log[source]

Bases: Math

Natural logarithm operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \ln(\vec{u})\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Log10[source]

Bases: Math

Base-10 logarithm operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \log_{10}(\vec{u})\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Tan[source]

Bases: Math

Tangent operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \tan(\vec{u})\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Sinh[source]

Bases: Math

Hyperbolic sine operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \sinh(\vec{u})\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Cosh[source]

Bases: Math

Hyperbolic cosine operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \cosh(\vec{u})\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Tanh[source]

Bases: Math

Hyperbolic tangent operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \tanh(\vec{u})\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Atan[source]

Bases: Math

Arctangent operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \arctan(\vec{u})\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Norm[source]

Bases: Math

Vector norm operator block.

This block computes the Euclidean norm of the input vector:

\[y = \|\vec{u}\|_2 = \sqrt{\sum_i u_i^2}\]
op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Mod(modulus=1.0)[source]

Bases: Math

Modulo operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \vec{u} \bmod m\]

Note

modulo is not differentiable at discontinuities

Parameters:

modulus (float) – modulus value

op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Clip(min_val=-1.0, max_val=1.0)[source]

Bases: Math

Clipping/saturation operator block.

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \text{clip}(\vec{u}, u_{min}, u_{max})\]
Parameters:
  • min_val (float, array_like) – minimum clipping value

  • max_val (float, array_like) – maximum clipping value

op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Matrix(A=array([[1.]]))[source]

Bases: Math

Linear matrix operation (matrix-vector product).

This block supports vector inputs. This is the operation it does:

\[\vec{y} = \mathbf{A} \vec{u}\]
Parameters:

A (np.ndarray) – matrix, 2d array with dim=2

op_alg

internal algebraic operator

Type:

Operator

class pathsim.blocks.math.Atan2[source]

Bases: Block

Two-argument arctangent block.

Computes the four-quadrant arctangent of two inputs:

\[y = \mathrm{atan2}(a, b)\]

Note

This block takes exactly two inputs (a, b) and produces one output. The first input is the y-coordinate, the second is the x-coordinate, matching the convention of numpy.arctan2(y, x).

op_alg

internal algebraic operator

Type:

Operator

input_port_labels = {'a': 0, 'b': 1}
output_port_labels = {'y': 0}
update(t)[source]

update algebraic component of system equation

Parameters:

t (float) – evaluation time

class pathsim.blocks.math.Rescale(i0=0.0, i1=1.0, o0=0.0, o1=1.0, saturate=False)[source]

Bases: Math

Linear rescaling / mapping block.

Maps the input linearly from range [i0, i1] to range [o0, o1]. Optionally saturates the output to [o0, o1].

\[y = o_0 + \frac{(x - i_0) \cdot (o_1 - o_0)}{i_1 - i_0}\]

This block supports vector inputs.

Parameters:
  • i0 (float) – input range lower bound

  • i1 (float) – input range upper bound

  • o0 (float) – output range lower bound

  • o1 (float) – output range upper bound

  • saturate (bool) – if True, clamp output to [min(o0,o1), max(o0,o1)]

op_alg

internal algebraic operator

Type:

Operator

property i0
property i1
property o0
property o1
property saturate
set(**kwargs)

Set multiple parameters and reinitialize once.

Parameters:

kwargs (dict) – parameter names and their new values

Example

block.set(K=5.0, T=0.3)
class pathsim.blocks.math.Alias[source]

Bases: Math

Signal alias / pass-through block.

Passes the input directly to the output without modification. This is useful for signal renaming in model composition.

\[y = x\]

This block supports vector inputs.

op_alg

internal algebraic operator

Type:

Operator