## status: correct ## teardown_command: rm PI_Controller.log PI_Controller.mat PI_Controller*.dot from OMSimulator import OMSimulator session = OMSimulator() session.setLogFile("PI_Controller.log") session.setTempDirectory("./PI_Controller_tmp") session.newFMIModel("PI_Controller") # instantiate FMUs session.addFMU("PI_Controller", "../FMUs/Modelica.Blocks.Math.Add.fmu", "addP") session.addFMU("PI_Controller", "../FMUs/Modelica.Blocks.Math.Gain.fmu", "P") session.addFMU("PI_Controller", "../FMUs/Modelica.Blocks.Math.Add3.fmu", "addI") session.addFMU("PI_Controller", "../FMUs/Modelica.Blocks.Continuous.Integrator.fmu", "I") session.addFMU("PI_Controller", "../FMUs/Modelica.Blocks.Math.Add.fmu", "addPI") session.addFMU("PI_Controller", "../FMUs/Modelica.Blocks.Math.Gain.fmu", "gainPI") session.addFMU("PI_Controller", "../FMUs/Modelica.Blocks.Nonlinear.Limiter.fmu", "limiter") session.addFMU("PI_Controller", "../FMUs/Modelica.Blocks.Math.Add.fmu", "addSat") session.addFMU("PI_Controller", "../FMUs/Modelica.Blocks.Math.Gain.fmu", "gainTrack") # add connections session.addConnection("PI_Controller", "addP:y", "P:u")
## status: correct ## teardown_command: rm DualMassOscillator_cs.log DualMassOscillator_cs.mat from OMSimulator import OMSimulator session = OMSimulator() session.setLogFile("DualMassOscillator_cs.log") session.newFMIModel("DualMassOscillator") session.setTempDirectory("./DualMassOscillator_cs_tmp") # instantiate FMUs session.addFMU("DualMassOscillator", "../FMUs/DualMassOscillator.System1_cs.fmu", "System1") session.addFMU("DualMassOscillator", "../FMUs/DualMassOscillator.System2_cs.fmu", "System2") # add connections session.addConnection("DualMassOscillator", "System1:F", "System2:F") session.addConnection("DualMassOscillator", "System1:s", "System2:s") session.addConnection("DualMassOscillator", "System1:v", "System2:v") session.addConnection("DualMassOscillator", "System1:a", "System2:a") session.setResultFile("DualMassOscillator", "DualMassOscillator_cs.mat") session.setStopTime("DualMassOscillator", 0.1) session.setCommunicationInterval("DualMassOscillator", 1e-5) session.initialize("DualMassOscillator") session.simulate("DualMassOscillator") (_, tcur) = session.getCurrentTime("DualMassOscillator") vars = ["DualMassOscillator.System1:mass1.s", "DualMassOscillator.System2:mass2.s"]
from OMSimulator import OMSimulator from OMSysIdent import OMSysIdent import numpy as np session = OMSimulator() version = session.getVersion() session.setLogFile("HelloWorld_cs_Fit_py.log") session.setTempDirectory(".") model = "HelloWorld_cs_Fit" session.newFMIModel(model) # session.setTolerance(model, 1e-5) # 2018-04-25 Not yet supported in oms2 API # add FMU session.addFMU(model, "../FMUs/HelloWorld_cs.fmu", "HelloWorld") # create simodel for model simodel = OMSysIdent(model) # simodel.describe() # Data generated from simulating HelloWorld.mo for 1.0s with Euler and 0.1s step size kNumSeries = 1 kNumObservations = 11 data_time = np.array([0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]) inputvars = [] measurementvars = ["HelloWorld:x"] data_x = np.array([ 1, 0.9, 0.8100000000000001, 0.7290000000000001, 0.6561, 0.5904900000000001, 0.5314410000000001, 0.4782969000000001, 0.43046721, 0.387420489, 0.3486784401
## status: correct ## teardown_command: rm RealNetwork1.log RealNetwork1.mat from OMSimulator import OMSimulator oms = OMSimulator() oms.setLogFile("RealNetwork1.log") oms.newFMIModel("RealNetwork1") oms.setTempDirectory("./RealNetwork1_tmp") # instantiate FMUs oms.addFMU("RealNetwork1", "../FMUs/Modelica.Blocks.Math.Add.fmu", "add") oms.addFMU("RealNetwork1", "../FMUs/Modelica.Blocks.Math.Feedback.fmu", "feedback") oms.addFMU("RealNetwork1", "../FMUs/Modelica.Blocks.Math.Gain.fmu", "gain") oms.addFMU("RealNetwork1", "../FMUs/Modelica.Blocks.Math.Product.fmu", "product") oms.addFMU("RealNetwork1", "../FMUs/Modelica.Blocks.Sources.Clock.fmu", "clock") oms.addFMU("RealNetwork1", "../FMUs/Modelica.Blocks.Sources.Constant.fmu", "constant") oms.addFMU("RealNetwork1", "../FMUs/Modelica.Blocks.Sources.Sine.fmu", "sine") oms.addFMU("RealNetwork1", "../FMUs/Modelica.Blocks.Sources.Step.fmu", "step") # add connections oms.addConnection("RealNetwork1", "clock:y", "product:u1") oms.addConnection("RealNetwork1", "constant:y", "add:u2") oms.addConnection("RealNetwork1", "feedback:y", "add:u1") oms.addConnection("RealNetwork1", "gain:y", "feedback:u1") oms.addConnection("RealNetwork1", "product:y", "gain:u") oms.addConnection("RealNetwork1", "sine:y", "feedback:u2") oms.addConnection("RealNetwork1", "step:y", "product:u2")