-
Notifications
You must be signed in to change notification settings - Fork 36
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
Combine Blocks into new Block #28
Comments
Hi, You mean some kind of meta-block? It's not possible yet but not so difficult to implement. |
Exactly. I simulated a simple control system today where the plant is a simple first order lag and a gain. Now I created a subclass of ODE for the first order lag and used it in combination with your gain block. Now I would like to combine those two into a "plant" block. I know I can just create a ODE block that combines the lag and the gain but with a more complex system I would not want to do this because it kind of defeats the purpose of the block based approach. |
If you want to propose a pull request, you can add in core.py a MetaBlock class, inherinting from Block that takes a list of block as input. |
I don't know how to handle variables that way. Heres my approach: from bms import DynamicSystem, Variable
from bms.signals.functions import Step
from bms.blocks.continuous import ODE, Gain
class FirstOrderLag(ODE):
def __init__(self, input_variable, output_variable, tau):
a = [1]
b = [1, tau]
super().__init__(input_variable, output_variable, a, b)
def Plant(input, output):
temp = Variable('temp', hidden=True)
lag = FirstOrderLag(source, temp, tau=11e-3)
gain = Gain(temp, output, value=-50e3)
return [
lag,
gain
]
source = Step('source', amplitude=0.9, delay=50e-3)
output = Variable('output')
plant = Plant(source, output)
end_time = 150e-3
number_of_time_steps = 1000
model = DynamicSystem(end_time, number_of_time_steps, [
*plant
])
model.Simulate()
model.PlotVariables() Is there a better way? |
You can try to have "local" variables in your block that the dynamic don't know |
Hi @masfaraud
I love your project. Is there a way to combine multiple blocks into a new block?
The text was updated successfully, but these errors were encountered: