Organizing Modelica code...

2 posts / 0 new
Last post
Joined: 2010-09-11
Organizing Modelica code...



So far I have had my library of Modelica models in a single file and the content enclosed by package PROCESS_LIB….. end PROCESS_LIB; 


Part of of the code is now within a sub-package called package CUSTOMER_LIB…. end CUSTOMER_LIB; 


The python-script to administrate this use the following code to compile:

model_name = ‘PROCESS_LIB.CUSTOMER.Batch’

mobile = “PROCESS_LIB_v1’

fmu_model = compile_fmu(model_name,mofile)


(And here Batch is customer model that combines different sub-models to run the process in batch mode).


This works as expected.


Now I would like split this file into two parts.

One general part for PROCESS_LIB and one CUSTOMER_LIB part.


How should this be done?

What should be added in the code?


I have read about Modelica concepts like MODELICAPATH, WITHIN, IMPORT etc, but I find it difficult to make it work and also wonder if here is some special limitations around the compile_fmu command.


I also read in the JModelica manual section 4.2.3 and try to make compile_fmu to search in a folder for a model instead of giving a file for it. Did not work.


I also looked at earlier thread and found that my MODELICAPATH did not exist at all. Still I can compile MSL model as described in section 4.2.3. Something wrong in my installation?


Would appreciate some input.


Jan Peter


PS I run JModelica ver 2.0 in Windows 10 as virtual machine on a Mac.

Joined: 2010-09-11
Hi, I have got some better


I have got some better insight into structuring Modelica code in the post "Modelica in Action: How to structure models in packges" by Marco Bonvini But there is more to learn here.

I also found it useful to address other directoreis not in the MODELICAPATH explaing here

Still I would like to be able to update my MODELICAPATH. As said above the post does not seem relevant for JModelica ver 2.0. 

In Windows 10 (latest update) it is somewhat involved to set the MODELICAPATH and I have looked around "Envirnoment Variables" but cannot find the current MODELICAPATH, see enclosed screenshot. Where is it? and how do I modify it?

Would appreicate some help

Jan Peter

Screen Shot 2017-10-10 at 11.36.48.png 41.23 KB
Login or register to post comments