コード例 #1
0
    def GetCompatibleSolvers(this):
        from PySimLib import FindSolver

        solvers = []

        solvers.append(FindSolver("dassl"))
        solvers.append(FindSolver("euler"))

        return solvers
コード例 #2
0
    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
コード例 #3
0
    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"))
コード例 #4
0
    def GetCompatibleSolvers(this):
        from PySimLib import FindSolver

        solvers = []

        for key in Dymola.__solverMap:
            solvers.append(FindSolver(key))

        return solvers
コード例 #5
0
    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) + "'")
コード例 #6
0
    def GetDefaultSolver(this):
        from PySimLib import FindSolver

        return FindSolver("dassl")