Text based control algorithim for modelica
Hello all, I am trying to model a microgrid simulation using the modelica buildings library. I am using OMEdit to model the system, but would prefer to write the code for the control algorithm for the bi-directional battery inverter in text format as I come from C/Python background and find it easier to follow compared to a visual system. I wrote this code:
model battery_control
Modelica.Blocks.Interfaces.RealInput SOC;
Modelica.Blocks.Interfaces.RealOutput inverterInput;
Modelica.Blocks.Interfaces.RealInput meterInput;
equation
if (meterInput <= -20) and (SOC > 20) and (meterInput >= -100) then
inverterInput = abs(inverterInput + 20);
elseif (meterInput >= -100) and (SOC > 20) then
inverterInput = 100;
elseif (meterInput >= 5) and (SOC < 90) and (meterInput < 100 ) then
inverterInput = -1 * (inverterInput - 5);
elseif (SOC < 90) and (meterInput < 100 ) then
inverterInput = -100
else
inverterInput = 0;
end if;
end battery_control;
However, OMEdit does not let me save this code. I am not sure what is wrong. Basically, I want to create a block that connects to the input and ouput, but it is text-based control. Also, is it possble to run python code in modelica, not the reverse(run modelica in python: PyFmi). Thank you for the help.