def _set_solver_options(self): """ Helper function that sets options for the solver. """ solver_options = self.solver_options.copy() #Set solver option continuous_output self.simulator.report_continuously = True if not solver_options.has_key("usejac") and isinstance( self.model, fmi.FMUModelME2): solver_options["usejac"] = not self.model.get_capability_flags( )['providesDirectionalDerivatives'] #loop solver_args and set properties of solver for k, v in solver_options.items(): try: getattr(self.simulator, k) except AttributeError: try: getattr(self.probl, k) except AttributeError: raise InvalidSolverArgumentException(k) setattr(self.probl, k, v) continue setattr(self.simulator, k, v)
def _set_solver_options(self): """ Helper function that sets options for the solver. """ solver_options = self.solver_options.copy() #Set solver option continuous_output self.simulator.report_continuously = True #If usejac is not set, try to set it according to if directional derivatives #exists. Also verifies that the option "usejac" exists for the solver. #(Only check for FMI2) if self.with_jacobian and not "usejac" in solver_options: try: getattr(self.simulator, "usejac") solver_options["usejac"] = True except AttributeError: pass #Override usejac if there are no states fnbr, gnbr = self.model.get_ode_sizes() if "usejac" in solver_options and fnbr == 0: solver_options["usejac"] = False if "maxh" in solver_options and solver_options["maxh"] == "Default": if self.options["ncp"] == 0: solver_options["maxh"] = 0.0 else: solver_options["maxh"] = float(self.final_time - self.start_time) / float(self.options["ncp"]) #loop solver_args and set properties of solver for k, v in solver_options.items(): try: getattr(self.simulator,k) except AttributeError: try: getattr(self.probl,k) except AttributeError: raise InvalidSolverArgumentException(k) setattr(self.probl, k, v) continue setattr(self.simulator, k, v) #Needs to be set as last option in order to have an impact. if "maxord" in solver_options: setattr(self.simulator, "maxord", solver_options["maxord"])
def _set_solver_options(self): """ Helper function that sets options for the solver. """ solver_options = self.solver_options.copy() #Set solver option continuous_output self.simulator.report_continuously = True #If usejac is not set, try to set it according to if directional derivatives #exists. Also verifies that the option "usejac" exists for the solver. #(Only check for FMI2) if self.with_jacobian and not "usejac" in solver_options: try: getattr(self.simulator, "usejac") solver_options["usejac"] = True except AttributeError: pass elif not "usejac" in solver_options and (isinstance(self.model, fmi.FMUModelME2) or isinstance(self.model, fmi_coupled.CoupledFMUModelME2)): try: getattr(self.simulator, "usejac") solver_options["usejac"] = self.model.get_capability_flags()['providesDirectionalDerivatives'] except AttributeError: pass #Override usejac if there are no states fnbr, gnbr = self.model.get_ode_sizes() if "usejac" in solver_options and fnbr == 0: solver_options["usejac"] = False #loop solver_args and set properties of solver for k, v in solver_options.items(): try: getattr(self.simulator,k) except AttributeError: try: getattr(self.probl,k) except AttributeError: raise InvalidSolverArgumentException(k) setattr(self.probl, k, v) continue setattr(self.simulator, k, v) #Needs to be set as last option in order to have an impact. if "maxord" in solver_options: setattr(self.simulator, "maxord", solver_options["maxord"])
def _set_solver_options(self): """ Helper function that sets options for the solver. """ solver_options = self.solver_options.copy() #Set solver option continuous_output self.simulator.continuous_output = self.options["continuous_output"] #loop solver_args and set properties of solver for k, v in solver_options.iteritems(): try: getattr(self.simulator, k) except AttributeError: try: getattr(self.probl, k) except AttributeError: raise InvalidSolverArgumentException(k) setattr(self.probl, k, v) continue setattr(self.simulator, k, v)