def GetCompatibleSolvers(this): from PySimLib import FindSolver solvers = [] solvers.append(FindSolver("dassl")) solvers.append(FindSolver("euler")) return solvers
def ReadInit(this, mdl): from PySimLib import FindSolver from PySimLib.VariableDescriptor import VariableDescriptor mdl.startTime = None mdl.stopTime = None mdl.solver = FindSolver("dassl") # TODO!!!! this.__EnsureMatlabConnectionIsSetup() cmd = "clear;" # make sure workspace is clean cmd += "cd " + mdl.simDir + ";" # go to sim dir Simulink.__matlabConnection.run_code(cmd) # exec init file if (this._FileExists(mdl.simDir + os.sep + mdl.GetName() + "_init.m")): Simulink.__matlabConnection.run_code(mdl.GetName() + "_init;") # get all variables varList = Simulink.__matlabConnection.get_variable('who') for x in varList: name = x[0][0] value = Simulink.__matlabConnection.get_variable(x[0][0]) var = VariableDescriptor() var.start = value mdl.variables[name] = var
def ReadInit(this, mdl): from PySimLib import FindSolver initDom = this.__GetInitFileXML(mdl) mv = initDom.getElementsByTagName("ModelVariables")[0] de = initDom.getElementsByTagName("DefaultExperiment")[0] #read parameters classTypeFilter = { "iPar", #integer parameter "rPar", #real parameter } parameters = this.__ReadVarsFromXML(mv, classTypeFilter) for name in parameters: mdl.parameters[name] = parameters[name].start #read variables classTypeFilter = { "bAlg", #boolean algebraic "iAlg", #integer algebraic "rAlg", #real algebraic "rSta", #state variables } mdl.variables = this.__ReadVarsFromXML(mv, classTypeFilter) #read experiment values mdl.startTime = de.getAttribute("startTime") mdl.stopTime = de.getAttribute("stopTime") mdl.solver = FindSolver(de.getAttribute("solver")) mdl.solver.stepSize = float(de.getAttribute("stepSize")) mdl.solver.tolerance = float(de.getAttribute("tolerance"))
def GetCompatibleSolvers(this): from PySimLib import FindSolver solvers = [] for key in Dymola.__solverMap: solvers.append(FindSolver(key)) return solvers
def __ReverseMapSolver(this, solverNumber): from PySimLib import FindSolver solverNumber = int(solverNumber) for key in Dymola.__solverMap: if(Dymola.__solverMap[key] == solverNumber): return FindSolver(key) raise Exception("Illegal solver number '" + str(solverNumber) + "'")
def GetDefaultSolver(this): from PySimLib import FindSolver return FindSolver("dassl")