Skip to content

Commit

Permalink
Update documentation (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel committed Mar 21, 2021
1 parent 58eb72f commit 535e12b
Show file tree
Hide file tree
Showing 71 changed files with 131 additions and 112 deletions.
24 changes: 21 additions & 3 deletions doc/UsersGuide/source/OMSimulatorPython.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ Python Scripting Commands
Example: Pi
###########

This example uses a simple Modelica model and FMI-based batch
simulation to approximate the value of pi.

A Modelica model is used to calculate two uniform distributed
pseudo-random numbers between 0 and 1 based on a seed value and
evaluates if the resulting coordinate is inside the unit circle or
not.

.. code-block:: modelica
model Circle
Expand All @@ -105,13 +113,20 @@ Example: Pi
algorithm
when initial() then
state128 := Modelica.Math.Random.Generators.Xorshift128plus.initialState(localSeed, globalSeed);
(x/r, state128) := Modelica.Math.Random.Generators.Xorshift128plus.random(state128);
(y/r, state128) := Modelica.Math.Random.Generators.Xorshift128plus.random(state128);
(x, state128) := Modelica.Math.Random.Generators.Xorshift128plus.random(state128);
(y, state128) := Modelica.Math.Random.Generators.Xorshift128plus.random(state128);
end when;
annotation(uses(Modelica(version="4.0.0")));
end Circle;
The model is then exported using the FMI interface and the generated
FMU can then be used to run a million simulations in just a few
seconds.

.. code-block:: python
:caption: Batch simulation of the simple `Cirlce` model with different seed values. All OMSimulator-related comands are highlighted for convenience.
:linenos:
:emphasize-lines: 3,5-6,8-10,12-13,22-25,29-30
import math
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -149,6 +164,9 @@ Example: Pi
plt.ylabel('Approximation of pi')
plt.savefig('pi.png')
The following figure shows the approximation of pi in relation to the
number of samples.

.. figure :: images/pi.png
Results: Approximation of pi
Results of the above batch simulation which approximates the value of pi
3 changes: 2 additions & 1 deletion doc/UsersGuide/source/OpenModelicaScripting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OMSimulatorLib library.
Examples
########

.. code-block:: Modelica
.. code-block:: modelica
loadOMSimulator();
oms_setTempDirectory("./temp/");
Expand Down Expand Up @@ -39,6 +39,7 @@ Examples
oms_terminate("model");
oms_delete("model");
unloadOMSimulator();
.. index:: OpenModelicaScripting; Scripting Commands

OpenModelica Scripting Commands
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/addBus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Adds a bus to a given component.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addBus(cref);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/addConnection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ specified as fully qualified component references, e.g., `"model.system.componen
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addConnection(crefA, crefB);
Expand Down
40 changes: 20 additions & 20 deletions doc/UsersGuide/source/api/addConnector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ Adds a connector to a given component.
.. code-block:: lua
status = oms_addConnector(cref, causality, type)
The second argument "causality", should be any of the following,
oms_causality_input
oms_causality_output
oms_causality_output
oms_causality_parameter
oms_causality_bidir
oms_causality_undefined
The third argument "type", should be any of the following,
oms_signal_type_real
oms_signal_type_integer
oms_signal_type_boolean
Expand All @@ -34,24 +34,24 @@ Adds a connector to a given component.
.. code-block:: python
status = oms.addConnector(cref, causality, type)
The second argument "causality", should be any of the following,
oms.input
oms.output
oms.output
oms.parameter
oms.bidir
oms.undefined
The third argument "type", should be any of the following,
oms.signal_type_real
oms.signal_type_integer
oms.signal_type_boolean
oms.signal_type_string
oms.signal_type_enum
oms.signal_type_bus
#END#

Expand All @@ -63,20 +63,20 @@ Adds a connector to a given component.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addConnector(cref, causality, type);
The second argument "causality", should be any of the following,
"OpenModelica.Scripting.oms_causality.oms_causality_input"
"OpenModelica.Scripting.oms_causality.oms_causality_output"
"OpenModelica.Scripting.oms_causality.oms_causality_parameter"
"OpenModelica.Scripting.oms_causality.oms_causality_bidir"
"OpenModelica.Scripting.oms_causality.oms_causality_input"
"OpenModelica.Scripting.oms_causality.oms_causality_output"
"OpenModelica.Scripting.oms_causality.oms_causality_parameter"
"OpenModelica.Scripting.oms_causality.oms_causality_bidir"
"OpenModelica.Scripting.oms_causality.oms_causality_undefined"
The third argument type, should be any of the following,
"OpenModelica.Scripting.oms_signal_type.oms_signal_type_real"
"OpenModelica.Scripting.oms_signal_type.oms_signal_type_integer"
"OpenModelica.Scripting.oms_signal_type.oms_signal_type_boolean"
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/addConnectorToBus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Adds a connector to a bus.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addConnectorToBus(busCref, connectorCref);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/addConnectorToTLMBus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Adds a connector to a TLM bus.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addConnectorToTLMBus(busCref, connectorCref, type);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/addExternalModel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Adds an external model to a TLM system.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addExternalModel(cref, path, startscript);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/addSignalsToResults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Add all variables that match the given regex to the result file.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addSignalsToResults(cref, regex);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/addSubModel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Adds a component to a system.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addSubModel(cref, fmuPath);
Expand Down
6 changes: 3 additions & 3 deletions doc/UsersGuide/source/api/addSystem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Adds a (sub-)system to a model or system.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addSystem(cref, type);
The second argument type, should be any of the following,
"OpenModelica.Scripting.oms_system.oms_system_none"
"OpenModelica.Scripting.oms_system.oms_system_tlm"
"OpenModelica.Scripting.oms_system.oms_system_tlm"
"OpenModelica.Scripting.oms_system.oms_system_sc"
"OpenModelica.Scripting.oms_system.oms_system_wc"
Expand Down
32 changes: 16 additions & 16 deletions doc/UsersGuide/source/api/addTLMBus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ Adds a TLM bus.
.. code-block:: lua
status = oms_addTLMBus(cref, domain, dimensions, interpolation)
The second argument "domain", should be any of the following,
The second argument "domain", should be any of the following,
oms_tlm_domain_input
oms_tlm_domain_output
oms_tlm_domain_mechanical
oms_tlm_domain_rotational
oms_tlm_domain_hydraulic
oms_tlm_domain_electric
The fourth argument "interpolation", should be any of the following,
oms_tlm_no_interpolation
oms_tlm_coarse_grained
oms_tlm_fine_grained
Expand All @@ -31,18 +31,18 @@ Adds a TLM bus.
.. code-block:: python
status = oms.addTLMBus(cref, domain, dimensions, interpolation)
The second argument "domain", should be any of the following,
The second argument "domain", should be any of the following,
oms.tlm_domain_input
oms.tlm_domain_output
oms.tlm_domain_mechanical
oms.tlm_domain_rotational
oms.tlm_domain_hydraulic
oms.tlm_domain_electric
The fourth argument "interpolation", should be any of the following,
oms.default
oms.coarsegrained
oms.finegrained
Expand All @@ -57,21 +57,21 @@ Adds a TLM bus.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addTLMBus(cref, domain, dimensions, interpolation);
The second argument "domain", should be any of the following,
The second argument "domain", should be any of the following,
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_input"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_output"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_mechanical"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_rotational"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_hydraulic"
"OpenModelica.Scripting.oms_tlm_domain.oms_tlm_domain_electric"
The fourth argument "interpolation", should be any of the following,
"OpenModelica.Scripting.oms_tlm_interpolation.oms_tlm_no_interpolation"
"OpenModelica.Scripting.oms_tlm_interpolation.oms_tlm_coarse_grained"
"OpenModelica.Scripting.oms_tlm_interpolation.oms_tlm_fine_grained"
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/addTLMConnection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Connects two TLM connectors.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_addTLMConnection(crefA, crefB, delay, alpha, linearimpedance, angularimpedance);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/compareSimulationResults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ relative tolerances.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_compareSimulationResults(filenameA, filenameB, var, relTol, absTol);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/copySystem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Copies a system.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_copySystem(source, target);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/delete.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Deletes a connector, component, system, or model object.


#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_delete(cref);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/deleteConnection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Deletes the connection between connectors `crefA` and `crefB`.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_deleteConnection(crefA, crefB);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/deleteConnectorFromBus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Deletes a connector from a given bus.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_deleteConnectorFromBus(busCref, connectorCref);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/deleteConnectorFromTLMBus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Deletes a connector from a given TLM bus.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_deleteConnectorFromTLMBus(busCref, connectorCref);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Exports a composite model to a SPP file.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_export(cref, filename);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/exportDependencyGraphs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Export the dependency graphs of a given model to dot files.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
status := oms_exportDependencyGraphs(cref, initialization, event, simulation);
Expand Down
2 changes: 1 addition & 1 deletion doc/UsersGuide/source/api/exportSnapshot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ doesn't need to call free.
#END#

#OMC#
.. code-block:: Modelica
.. code-block:: modelica
(contents, status) := oms_exportSnapshot(cref);
Expand Down

0 comments on commit 535e12b

Please sign in to comment.