Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)

Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » BigMautone
  • » Profile



Jun-17-22 09:59:23
I wrote a script in python for override some parameters of a record class, but they don't...
Category: Programming

I'm trying to simulate a system made by me. I modeled a swarm of drones and the system made in openmodelica have to simulate them flying and avoiding obstacles or intruders into the flyzone. Now, i want to summarize results of the system simulation with different parameters (e.g. number of drones, number of obstacoles, ...) and i made a python script for doing it. The problem is that all this parameters is stored in a record class, named K,  and the parameters don't want to change. this is the piece of script where i change the parameters:


def startSimulation(n, intr, miss, statObs, fault, flyZone):
#Overwrite parameters
    with open("newValues.txt", 'wt') as f:
        for i in range(len(fault)):
            for j in range(len(fault[i])):
        for i in range(3):

    os.system("./System -overrideFile=newValues.txt >> LogOverride.txt")

for more context, this is the github repository of this project: The python file is, the system file is and the record class is called

If i check the System_init.xml file, i can see that lots of parameter of record class K have the flag "isValueChangeble" equals to false. How can i change it?

Problem solved, find a solution here: … 0#72140240

i'm developing a system in openmodelica which design the behaviour of a swarm of drone in various simulation. Now, i want to get the simulation result with OMPython, because i will use matplotlib to make charts of the various KPI. If i want to get values, the openmodelica scripting function requires:

    val(String valueName, Real timePoint, String file);

And i want to take the value at the end of the simulation. The problem is that the simulation stop time is not constant! So, is there a function to retrieve the stop time of the simulation?

I managed to retrieve this information in python using the "simulate" function. But i want to use BuildModel function, because with it i can change variables in the system and simulate again without any problem. any suggestion?

  • Index
  • » Users
  • » BigMautone
  • » Profile
You are here: