Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions OMPython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class which means it will use OMCSessionZMQ by default. If you want to use
from collections import OrderedDict
import numpy as np
import pyparsing
import importlib


if sys.platform == 'darwin':
Expand Down Expand Up @@ -1766,11 +1767,10 @@ def linearize(self, lintime = None, simflags= None): # 22
# this function is called from the generated python code linearized_model.py at runtime,
# to improve the performance by directly reading the matrices A, B, C and D from the julia code and avoid building the linearized modelica model
try:
## add the generated linearfile directory to system path, as running from script does not find the module
## do not add the linearfile directory to path, as multiple execution of linearization will always use the first added path, instead execute the file
## https://github.com/OpenModelica/OMPython/issues/196
sys.path.append(os.path.dirname(linearFile))
from linearized_model import linearized_model
result = linearized_model()
module = importlib.machinery.SourceFileLoader("linearized_model", linearFile).load_module()
result = module.linearized_model()
(n, m, p, x0, u0, A, B, C, D, stateVars, inputVars, outputVars) = result
self.linearinputs = inputVars
self.linearoutputs = outputVars
Expand Down