Changeset 7df27713 in OpenModelica
- Timestamp:
- 2019-01-15T13:16:37+01:00 (5 years ago)
- Branches:
- Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, master, omlib-staging
- Children:
- d663c40
- Parents:
- a5b0f222
- git-author:
- Lennart Ochel <lennart.ochel@…> (01/15/19 13:16:37)
- git-committer:
- hudson <openmodelica@…> (01/15/19 13:16:37)
- Location:
- omsimulator
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
omsimulator/DualMassOscillator.mo
ra5b0f222 r7df27713 9 9 Modelica.Mechanics.Translational.Components.Fixed fixed(s0=0.0) annotation( 10 10 Placement(transformation(extent={{-10,-10}, {10,10}}, rotation=0, origin={-70,0}))); 11 Modelica.Mechanics.Translational.Components.Mass mass1( m=m1, s(fixed=true, start=s1_start), v(fixed=true, start=v1_start), L=0.0) annotation(11 Modelica.Mechanics.Translational.Components.Mass mass1( L=0.0, m=m1, s(fixed=true, start=s1_start), v(fixed=true, start=v1_start)) annotation( 12 12 Placement(transformation(extent={{-14,-10}, {6,10}}))); 13 13 Modelica.Mechanics.Translational.Components.SpringDamper springDamper1(c=c1, d=d1, s_rel0=1.0) annotation( … … 23 23 Modelica.Blocks.Interfaces.RealInput F annotation( 24 24 Placement(transformation(extent={{120,-10}, {100,10}}), iconTransformation(extent={{120,-10}, {100,10}}))); 25 Modelica.Blocks.Interfaces.RealOutput s annotation(25 Modelica.Blocks.Interfaces.RealOutput s1 annotation( 26 26 Placement(transformation(extent={{100,-40}, {120,-20}}), iconTransformation(extent={{100,-40}, {120,-20}}))); 27 Modelica.Blocks.Interfaces.RealOutput v annotation(27 Modelica.Blocks.Interfaces.RealOutput v1 annotation( 28 28 Placement(transformation(extent={{100,-60}, {120,-40}}), iconTransformation(extent={{100,-60}, {120,-40}}))); 29 Modelica.Blocks.Interfaces.RealOutput a annotation(29 Modelica.Blocks.Interfaces.RealOutput a1 annotation( 30 30 Placement(transformation(extent={{100,-80}, {120,-60}}), iconTransformation(extent={{100,-80}, {120,-60}}))); 31 31 equation … … 42 42 connect(force.flange, mass1.flange_b) annotation( 43 43 Line(points={{20,0}, {6,0}}, color={0,127,0})); 44 connect(accSensor.a, a ) annotation(44 connect(accSensor.a, a1) annotation( 45 45 Line(points={{41,-70}, {110,-70}}, color={0,0,127})); 46 connect(speedSensor.v, v ) annotation(46 connect(speedSensor.v, v1) annotation( 47 47 Line(points={{41,-50}, {110,-50}}, color={0,0,127})); 48 connect(positionSensor.s, s ) annotation(48 connect(positionSensor.s, s1) annotation( 49 49 Line(points={{41,-30}, {110,-30}}, color={0,0,127})); 50 50 connect(force.f, F) annotation( … … 62 62 parameter Real dc = 14.1421; 63 63 64 Real s2 = mass2.s; 65 64 66 Modelica.Mechanics.Translational.Components.Fixed fixed(s0=3.0) annotation( 65 67 Placement(transformation(extent={{80, -10}, {100, 10}}))); 66 Modelica.Mechanics.Translational.Components.Mass mass2( m=m2, s(fixed=true, start=s2_start), v(fixed=true, start=v2_start), L=0.0) annotation(68 Modelica.Mechanics.Translational.Components.Mass mass2( L=0.0, m=m2, s(fixed=true, start=s2_start), v(fixed=true, start=v2_start)) annotation( 67 69 Placement(transformation(extent={{20, -10}, {40, 10}}))); 68 70 Modelica.Mechanics.Translational.Components.SpringDamper springDamper2(c=c2, d=d2, s_rel0=1.0) annotation( … … 72 74 Modelica.Blocks.Interfaces.RealOutput F annotation( 73 75 Placement(transformation(extent={{-100, -10}, {-120, 10}}))); 74 Modelica.Blocks.Interfaces.RealInput s annotation(76 Modelica.Blocks.Interfaces.RealInput s1 annotation( 75 77 Placement(transformation(extent={{-120, -40}, {-100, -20}}))); 76 Modelica.Blocks.Interfaces.RealInput v annotation(78 Modelica.Blocks.Interfaces.RealInput v1 annotation( 77 79 Placement(transformation(extent={{-120, -60}, {-100, -40}}))); 78 Modelica.Blocks.Interfaces.RealInput a annotation(80 Modelica.Blocks.Interfaces.RealInput a1 annotation( 79 81 Placement(transformation(extent={{-120, -80}, {-100, -60}}))); 80 82 Modelica.Mechanics.Translational.Sensors.ForceSensor forceSensor annotation( … … 85 87 connect(forceSensor.f, F) annotation( 86 88 Line(points={{-22, 11}, {-90, 11}, {-90, 0}, {-110, 0}}, color={0,0,127})); 87 connect(s , move.u[1]) annotation(89 connect(s1, move.u[1]) annotation( 88 90 Line(points={{-110, -30}, {-80, -30}, {-80, -1.33333}, {-70, -1.33333}}, color={0,0,127})); 89 connect(v , move.u[2]) annotation(91 connect(v1, move.u[2]) annotation( 90 92 Line(points={{-110, -50}, {-80, -50}, {-80, 0}, {-70, 0}}, color={0,0,127})); 91 connect(a , move.u[3]) annotation(93 connect(a1, move.u[3]) annotation( 92 94 Line(points={{-110, -70}, {-80, -70}, {-80, 1.33333}, {-70, 1.33333}}, color={0,0,127})); 93 95 connect(springDamper_coupling.flange_b, mass2.flange_a) annotation( … … 107 109 System1 system1 annotation( 108 110 Placement(transformation(extent={{-30, -10}, {-10, 10}}))); 109 System2 system2 (s2_start=2.5)annotation(111 System2 system2 annotation( 110 112 Placement(transformation(extent={{10, -10}, {30, 10}}))); 111 113 equation 112 114 connect(system2.F, system1.F) annotation( 113 115 Line(points={{9, 0}, {-9, 0}}, color={0,0,127})); 114 connect(system1.s , system2.s) annotation(116 connect(system1.s1, system2.s1) annotation( 115 117 Line(points={{-9, -3}, {-9, -3}, {9, -3}}, color={0,0,127})); 116 connect(system1.v , system2.v) annotation(118 connect(system1.v1, system2.v1) annotation( 117 119 Line(points={{-9, -5}, {-9, -5}, {9, -5}}, color={0,0,127})); 118 connect(system1.a , system2.a) annotation(120 connect(system1.a1, system2.a1) annotation( 119 121 Line(points={{-9, -7}, {-9, -7}, {9, -7}}, color={0,0,127})); 120 122 annotation(Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false))); … … 125 127 parameter Real v1_start = 0.0; 126 128 parameter Real m1 = 1.0; 127 parameter Real s2_start = 2. 5;129 parameter Real s2_start = 2.0; 128 130 parameter Real v2_start = 0.0; 129 131 parameter Real m2 = 1.0; … … 135 137 parameter Real dc = 14.1421; 136 138 139 Real s1 = mass1.s; 140 Real s2 = mass2.s; 141 137 142 Modelica.Mechanics.Translational.Components.Fixed fixed(s0=0.0) annotation( 138 143 Placement(transformation(extent={{-10, 10}, {10, -10}}, rotation=90, origin={-86, 0}))); 139 Modelica.Mechanics.Translational.Components.Mass mass1( m=m1, v(fixed=true, start=v1_start), L=0.0, s(fixed=true, start=s1_start)) annotation(144 Modelica.Mechanics.Translational.Components.Mass mass1( L=0.0, m=m1, s(fixed=true, start=s1_start), v(fixed=true, start=v1_start)) annotation( 140 145 Placement(transformation(extent={{-40, -10}, {-20, 10}}))); 141 146 Modelica.Mechanics.Translational.Components.SpringDamper springDamper1(c=c1, d=d1, s_rel0=1.0) annotation( … … 143 148 Modelica.Mechanics.Translational.Components.Fixed fixed1(s0=3.0) annotation( 144 149 Placement(transformation(extent={{-10, -10}, {10, 10}}, rotation=90, origin={86, 0}))); 145 Modelica.Mechanics.Translational.Components.Mass mass2( m=m2, v(fixed=true, start=v2_start), L=0.0, s(fixed=true, start=s2_start)) annotation(150 Modelica.Mechanics.Translational.Components.Mass mass2( L=0.0, m=m2, s(fixed=true, start=s2_start), v(fixed=true, start=v2_start)) annotation( 146 151 Placement(transformation(extent={{20, -10}, {40, 10}}))); 147 152 Modelica.Mechanics.Translational.Components.SpringDamper springDamper2(c=c2, d=d2, s_rel0=1.0) annotation( -
omsimulator/DualMassOscillator_me.mos
ra5b0f222 r7df27713 18 18 19 19 oms3_addConnection(\"DualMassOscillator.root.system1.F\", \"DualMassOscillator.root.system2.F\") 20 oms3_addConnection(\"DualMassOscillator.root.system1.s \", \"DualMassOscillator.root.system2.s\")21 oms3_addConnection(\"DualMassOscillator.root.system1.v \", \"DualMassOscillator.root.system2.v\")22 oms3_addConnection(\"DualMassOscillator.root.system1.a \", \"DualMassOscillator.root.system2.a\")20 oms3_addConnection(\"DualMassOscillator.root.system1.s1\", \"DualMassOscillator.root.system2.s1\") 21 oms3_addConnection(\"DualMassOscillator.root.system1.v1\", \"DualMassOscillator.root.system2.v1\") 22 oms3_addConnection(\"DualMassOscillator.root.system1.a1\", \"DualMassOscillator.root.system2.a1\") 23 23 24 24 oms3_setResultFile(\"DualMassOscillator\", \"\") … … 32 32 oms3_initialize(\"DualMassOscillator\") 33 33 print(\"info: Initialization\") 34 print(\"info: system1. mass1.s: \" .. oms3_getReal(\"DualMassOscillator.root.system1.mass1.s\"))35 print(\"info: system2. mass2.s: \" .. oms3_getReal(\"DualMassOscillator.root.system2.mass2.s\"))34 print(\"info: system1.s1: \" .. oms3_getReal(\"DualMassOscillator.root.system1.s1\")) 35 print(\"info: system2.s2: \" .. oms3_getReal(\"DualMassOscillator.root.system2.s2\")) 36 36 37 37 oms3_simulate(\"DualMassOscillator\") 38 38 print(\"info: Simulation\") 39 print(\"info: system1. mass1.s: \" .. oms3_getReal(\"DualMassOscillator.root.system1.mass1.s\"))40 print(\"info: system2. mass2.s: \" .. oms3_getReal(\"DualMassOscillator.root.system2.mass2.s\"))39 print(\"info: system1.s1: \" .. oms3_getReal(\"DualMassOscillator.root.system1.s1\")) 40 print(\"info: system2.s2: \" .. oms3_getReal(\"DualMassOscillator.root.system2.s2\")) 41 41 42 42 oms3_terminate(\"DualMassOscillator\") … … 46 46 system(getInstallationDirectoryPath() + "/bin/OMSimulator --ignoreInitialUnknowns=true DualMassOscillator_me.lua"); 47 47 48 simulate(DualMassOscillator.CoupledSystem, stopTime=0.1 ); getErrorString();49 val(system1. mass1.s, {0.0,0.1});50 val(system2. mass2.s, {0.0,0.1});48 simulate(DualMassOscillator.CoupledSystem, stopTime=0.1, simflags="-override=system2.s2_start=2.5"); getErrorString(); 49 val(system1.s1, {0.0,0.1}); 50 val(system2.s2, {0.0,0.1}); 51 51 52 52 // Result: … … 65 65 // info: No result file will be created 66 66 // info: Initialization 67 // info: system1. mass1.s: 1.068 // info: system2. mass2.s: 2.567 // info: system1.s1: 1.0 68 // info: system2.s2: 2.5 69 69 // info: Simulation 70 // info: system1. mass1.s: 0.911279797407971 // info: system2. mass2.s: 1.955633814739670 // info: system1.s1: 0.9112797974079 71 // info: system2.s2: 1.9556338147396 72 72 // info: Final Statistics for 'DualMassOscillator.root': 73 73 // NumSteps = 1301 NumRhsEvals = 1545 NumLinSolvSetups = 138 … … 76 76 // record SimulationResult 77 77 // resultFile = "DualMassOscillator.CoupledSystem_res.mat", 78 // simulationOptions = "startTime = 0.0, stopTime = 0.1, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'DualMassOscillator.CoupledSystem', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ' '",78 // simulationOptions = "startTime = 0.0, stopTime = 0.1, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'DualMassOscillator.CoupledSystem', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-override=system2.s2_start=2.5'", 79 79 // messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method. 80 80 // LOG_SUCCESS | info | The simulation finished successfully.
Note: See TracChangeset
for help on using the changeset viewer.