openmodelica

Dynamically switching connect in Modelica

爷,独闯天下 提交于 2019-12-10 20:18:58
问题 Assume I have a large connector involving all kinds of base types (Real, Integer, String, Boolean). How can I switch connections based on state events? I would like to do something like this: model switch input ComplicatedConnector icon[2]; output ComplicatedConnector ocon; input Real x; equation if x >= 0 then connect(ocon, icon[1]); else connect(ocon, icon[2]); end if; end switch; This does not work. How can it be properly expressed in Modelica? Answer based on comment by Adrian Pop. model

integration of function in modelica

心不动则不痛 提交于 2019-12-10 17:54:36
问题 I would like to perform integration of a function of a variable other than time in Modelica, but I don't know how to do it. For example, how can I evaluate the integral of x dx with upper limit 5 and lower limit 2? ∫x dx=x^2/2 回答1: Modelica was not designed to be a CAS (computer algebra system) as Maple, Mathematica or Matlab, but with a little coding you can do it anyway. The thing is that your problem can not be solved automatically symbolically with Modelica tools, but numerically yes. In

How can I call an OpenModelica model in Python with OMPython?

最后都变了- 提交于 2019-12-04 21:18:07
问题 I have an OpenModelica model made with OMEdit. In order to get a concrete example I designed the following: Now I would like to run the model in Python. I can do this by using OMPython. After importing OMPython and loading the files I use the following command to run the simulation: result = OMPython.execute("simulate(myGain, numberOfIntervals=2, outputFormat=\"mat\")") The simulation now runs and the results are written to a file. Now I would like to run the same model but with an different

Unit testing Modelica component library?

 ̄綄美尐妖づ 提交于 2019-12-04 12:01:54
问题 I'm creating a library of components in Modelica, and would appreciate some input on techniques for unit testing the package. So far I have a test package, consisting of a set of models, one per component. Each test model instantiates a component, and connects it to some very simple helper classes that provide the necessary inputs and outputs. This works fine when using it interactively in the OMEditor, but I'm looking for a more automated solution with pass/fail criteria etc. Should I start

Unit testing Modelica component library?

血红的双手。 提交于 2019-12-03 07:54:58
I'm creating a library of components in Modelica, and would appreciate some input on techniques for unit testing the package. So far I have a test package, consisting of a set of models, one per component. Each test model instantiates a component, and connects it to some very simple helper classes that provide the necessary inputs and outputs. This works fine when using it interactively in the OMEditor, but I'm looking for a more automated solution with pass/fail criteria etc. Should I start writing .mos scripts, or is there another/better way ? Thanks. Christoph I like how Openmodelica

Generating two random time depedant veariables with different sample periods

跟風遠走 提交于 2019-12-03 00:12:52
问题 Following this question, I'm trying to generate two time-dependent random functions omega1 and tau using this example. The difference is that I need to have two different sample periods of 0.05 and 0.17 for omega1 and tau respectively. I just duplicated the parts I thought would do the job: model testData extends Modelica.Icons.Example; import Modelica.Math.Random.Generators; import Modelica.Math.Random.Utilities; parameter Real k = 50.0; parameter Real J = 0.001; Real theta1; Real theta2;

OpenModelica modelling Coulomb friction: Translation Error, post-optimization module findZeroCrossings (simulation) failed

偶尔善良 提交于 2019-12-02 07:52:30
问题 I'm trying to simulate Coulomb friction in Modelica. The basic concept is to check if relative velocity speed between to surfaces is less than a constant and the external force which tried to slid surfaces against each other is less than maximum static friction force (normalForce * staticFrictionCoefficient) then the friction force is equal to negative of the external shear force. otherwise, the friction force is equal to the kinetic friction force (normalForce * kineticFrictionCoefficient)in

Integration Methods in OpenModelica

两盒软妹~` 提交于 2019-12-02 04:53:55
问题 I have noticed that there are several integration methods available in OpenModelica simulation setup. I dont know what these are. Can I get some sort of information regarding these? Will the quality of results vary if the integration methods are changed? 回答1: Short document on the integration methods available in OpenModelica: https://openmodelica.org/svn/OpenModelica/trunk/doc/SimulationRuntime/IntegrationAlgorithms/ Yes, the quality (simulation speed, even finding a solution) could vary if

Initial guesses for nonlinear algebraic eqtns

喜你入骨 提交于 2019-12-02 02:03:16
问题 I have a system of nonlinear algebraic equations to solve. How can I use computed values (with continuous-time variability) as initial guess for the variables of solution instead of using parameters as start values? Can initial equation section be used for this purpose? I have created a test model to explain the issue: model Teststartvalue Real value1=1000;//calculated by some model Real value2=-1000;//calculated by some model parameter Real InputValue = 100;//Input to model Real StartValue

Integration Methods in OpenModelica

寵の児 提交于 2019-12-02 00:48:29
I have noticed that there are several integration methods available in OpenModelica simulation setup. I dont know what these are. Can I get some sort of information regarding these? Will the quality of results vary if the integration methods are changed? Short document on the integration methods available in OpenModelica: https://openmodelica.org/svn/OpenModelica/trunk/doc/SimulationRuntime/IntegrationAlgorithms/ Yes, the quality (simulation speed, even finding a solution) could vary if you choose different methods. The default is dassl. 来源: https://stackoverflow.com/questions/24257285