diff --git a/pyDMPC/ControlFramework/System.py b/pyDMPC/ControlFramework/System.py index 97f6281..b21c4d2 100644 --- a/pyDMPC/ControlFramework/System.py +++ b/pyDMPC/ControlFramework/System.py @@ -124,6 +124,8 @@ def prep_cont_sys(cls): cls.contr_sys = ControlledSystem.PLCSys() elif cls.contr_sys_typ == "Modelica": cls.contr_sys = ControlledSystem.ModelicaSys() + elif cls.contr_sys_typ == "API": + cls.contr_sys = ControlledSystem.API() @classmethod def close_cont_sys(cls): @@ -258,26 +260,34 @@ def iterate(self): sub.get_inputs() inputs = sub.model.states.inputs[0] - if i == 1: + if i == 0: sub.inputs = [inputs[0] - 0.1, inputs[0] + 0.1] else: - sub.inputs = [inputs[0], sub.model.states.set_points[0]] + if (self.subsystems[0].inputs[0] < + self.subsystems[1].model.states.set_points[0]): + sub.inputs = [min(self.subsystems[0].inputs[0], + sub.model.states.set_points[0] - 0.5), + sub.model.states.set_points[0]] + else: + sub.inputs = [max(self.subsystems[0].inputs[0], + sub.model.states.set_points[0] + 0.5), + sub.model.states.set_points[0]] sub.inputs.sort() sub.optimize(interp = True) self.broadcast([i]) - for ino in range(0,8,1): + for ino in range(0,3,1): for i,sub in enumerate(self.subsystems): - if i == 1: + if i == 0: sub.get_inputs() inputs = sub.model.states.inputs[0] sub.inputs = [inputs[0] - 0.1, inputs[0] + 0.1] else: if sub.coup_vars_rec != []: - if (self.subsystems[1].inputs[0] < + if (self.subsystems[0].inputs[0] < self.subsystems[1].model.states.set_points[0]): sub.inputs = [min(sub.coup_vars_rec[0], sub.model.states.set_points[0] - 0.5), diff --git a/pyDMPC/ControlFramework/Time.py b/pyDMPC/ControlFramework/Time.py index 42c5f52..46e8c69 100644 --- a/pyDMPC/ControlFramework/Time.py +++ b/pyDMPC/ControlFramework/Time.py @@ -11,7 +11,7 @@ class Time: sys_time = 0 time_incr = Init.time_incr - contr_sys_typ = "Modelica" + contr_sys_typ = Init.contr_sys_typ def __init__(self): pass