pathsim.blocks.sources module
- class pathsim.blocks.sources.Constant(value=1)[source]
Bases:
BlockProduces a constant output signal (SISO)
- Parameters:
value (float) – constant defining block output
- class pathsim.blocks.sources.Source(func=<function Source.<lambda>>)[source]
Bases:
BlockSource that produces an arbitrary time dependent output, defined by the func (callable).
\[y(t) = \mathrm{func}(t)\]Note
This block is purely algebraic and its internal function (func) will be called multiple times per timestep, each time when Simulation._update(t) is called in the global simulation loop.
Example
For example a ramp:
from pathsim.blocks import Source src = Source(lambda t : t)
or a simple sinusoid with some frequency:
import numpy as np from pathsim.blocks import Source #some parameter omega = 100 #the function that gets evaluated def f(t): return np.sin(omega * t) src = Source(f)
Because the Source block only has a single argument, it can be used to decorate a function and make it a PathSim block. This might be handy in some cases to keep definitions concise and localized in the code:
import numpy as np from pathsim.blocks import Source #does the same as the definition above @Source def src(t): omega = 100 return np.sin(omega * t) #'src' is now a PathSim block
- Parameters:
func (callable) – function defining time dependent block output