当前位置: 首页>>代码示例>>Python>>正文


Python ODEsystem.__init__方法代码示例

本文整理汇总了Python中PyDSTool.Generator.ODEsystem.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python ODEsystem.__init__方法的具体用法?Python ODEsystem.__init__怎么用?Python ODEsystem.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyDSTool.Generator.ODEsystem的用法示例。


在下文中一共展示了ODEsystem.__init__方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyDSTool.Generator import ODEsystem [as 别名]
# 或者: from PyDSTool.Generator.ODEsystem import __init__ [as 别名]
    def __init__(self, kw):
        ODEsystem.__init__(self, kw)

        self.diagnostics._errorcodes = \
                {0: 'Unrecognized error code returned (see stderr output)',
                -1: 'Excess work done on this call. (Perhaps wrong method MF.)',
                -2: 'Excess accuracy requested. (Tolerances too small.)',
                -3: 'Illegal input detected. (See printed message.)',
                -4: 'Repeated error test failures. (Check all input.)',
                -5: 'Repeated convergence failures. (Perhaps bad'
                    ' Jacobian supplied or wrong choice of method MF or tolerances.)',
                -6: 'Error weight became zero during problem. (Solution'
                    ' component i vanished, and ATOL or ATOL(i) = 0.)'
                }
        self.diagnostics.outputStatsInfo = {'errorStatus': 'Error status on completion.'}
        # note: VODE only supports array atol, not rtol.
        algparams_def = {'poly_interp': False,
                         'rtol': 1e-9,
                         'atol': [1e-12 for dimix in range(self.dimension)],
                         'stiff': False,
                         'max_step': 0.0,
                         'min_step': 0.0,
                         'init_step': 0.01,
                         'max_pts': 1000000,
                         'strictdt': False,
                         'use_special': False,
                         'specialtimes': []
                         }
        for k, v in algparams_def.items():
            if k not in self.algparams:
                self.algparams[k] = v
开发者ID:F-A,项目名称:pydstool,代码行数:33,代码来源:Vode_ODEsystem.py

示例2: __init__

# 需要导入模块: from PyDSTool.Generator import ODEsystem [as 别名]
# 或者: from PyDSTool.Generator.ODEsystem import __init__ [as 别名]
 def __init__(self, kw):
     ODEsystem.__init__(self, kw)
     assert self.funcspec.targetlang == 'python', \
            ('Wrong target language for functional specification. '
             'Python needed for this class')
     assert isinstance(self.funcspec, RHSfuncSpec), ('Vode '
                                 'requires RHSfuncSpec type to proceed')
     self._paraminfo = {'init_step': 'Fixed step size for time mesh.',
                        'strictdt': 'Boolean determining whether to evenly space time mesh (default=False), or to use exactly dt spacing.',
                        'stiff': 'Boolean to activate the BDF method, otherwise Adams method used. Default False.'}
     self._errorcodes = {0: 'Unrecognized error code returned (see stderr output)',
             -1: 'Excess work done on this call. (Perhaps wrong method MF.)',
             -2: 'Excess accuracy requested. (Tolerances too small.)',
             -3: 'Illegal input detected. (See printed message.)',
             -4: 'Repeated error test failures. (Check all input.)',
             -5: 'Repeated convergence failures. (Perhaps bad'
                 ' Jacobian supplied or wrong choice of method MF or tolerances.)',
             -6: 'Error weight became zero during problem. (Solution'
                 ' component i vanished, and ATOL or ATOL(i) = 0.)'
             }
     self._outputinfo = {'errorStatus': 'Error status on completion.'}
     # note: VODE only supports array atol, not rtol.
     algparams_def = {'rtol': 1e-9,
                      'atol': [1e-12 for dimix in xrange(self.dimension)],
                      'stiff': False,
                      'max_step': 0.0,
                      'min_step': 0.0,
                      'init_step': 0.01,
                      'max_pts': 1000000,
                      'strictdt': False
                      }
     for k, v in algparams_def.iteritems():
         if k not in self._algparams:
             self._algparams[k] = v
     self.outputstats = {}
开发者ID:BenjaminBerhault,项目名称:Python_Classes4MAD,代码行数:37,代码来源:Vode_ODEsystem.py

示例3: __init__

# 需要导入模块: from PyDSTool.Generator import ODEsystem [as 别名]
# 或者: from PyDSTool.Generator.ODEsystem import __init__ [as 别名]
 def __init__(self, kw):
     if 'user_func_beforestep' in kw:
         self.ufunc_before = kw['user_func_beforestep']
         # delete because not covered in ODEsystem
         del kw['user_func_beforestep']
     else:
         self.ufunc_before = _dummy_userfunc
     if 'user_func_afterstep' in kw:
         self.ufunc_after = kw['user_func_afterstep']
         # delete because not covered in ODEsystem
         del kw['user_func_afterstep']
     else:
         self.ufunc_after = _dummy_userfunc
     ODEsystem.__init__(self, kw)
     self._paraminfo = {'init_step': 'Fixed step size for time mesh.'}
     self.diagnostics._errorcodes = {1: 'Step OK'}
     self.diagnostics.outputStatsInfo = {'errorStatus': 'Error status on completion.'}
     algparams_def = {'poly_interp': False,
                      'init_step': 0.01,
                      'max_pts': 100000
                      }
     for k, v in algparams_def.items():
         if k not in self.algparams:
             self.algparams[k] = v
开发者ID:pyroalf,项目名称:pydstool,代码行数:26,代码来源:Euler_ODEsystem.py

示例4: __init__

# 需要导入模块: from PyDSTool.Generator import ODEsystem [as 别名]
# 或者: from PyDSTool.Generator.ODEsystem import __init__ [as 别名]
    def __init__(self, kw):
        """Use the nobuild key to postpone building of the library, e.g. in
        order to provide additional build options to makeLibSource and
        compileLib methods or to make changes to the C code by hand.
        No build options can be specified otherwise."""

        # Building is just doing make
        if 'nobuild' in kw:
            nobuild = kw['nobuild']
            del kw['nobuild']
        else:
            nobuild = False
        ODEsystem.__init__(self, kw)
        self._solver = None
        assert self.funcspec.targetlang == 'matlab', \
               ('Wrong target language for functional specification. '
                'matlab needed for this class')
        assert isinstance(self.funcspec, RHSfuncSpec), ('ADMC++ '
                                    'requires RHSfuncSpec type to proceed')
        assert not self.inputs, \
                        'ADMC++ does not support external inputs feature'
        self._errorcodes = {}
        self._paraminfo = {}

        self.vftype = 'vfieldts'

        # currently the final four of these params are for event handling
        # NEED TO CHECK WHICH ONES ARE SUPPORTED BY ADMC -- LOOKS LIKE EVTOLS ONLY FOR NOW
        # HACK: vftype is alg param for now, tells us whether parent class is hybridvf, vfieldts, etc.
        algparams_def = {'evtols' : 0.0001, 'vftype' : 'vfieldts'}

        # Remove this later
        for k, v in algparams_def.iteritems():
            if k not in self.algparams:
                self.algparams[k] = v

        # verify that no additional keys are present in algparams, after
        # defaults are added above
        if len(self.algparams) != len(algparams_def):
            raise ValueError("Invalid keys present in algparams argument: " \
                     + str(remain(self.algparams.keys(),algparams_def.keys())))

        thisplatform = platform.system()

        self._compilation_tempdir = os.path.join(os.getcwd(),
                                                      "admcpp_temp")
        if not os.path.isdir(self._compilation_tempdir):
            try:
                assert not os.path.isfile(self._compilation_tempdir), \
                     "A file already exists with the same name"
                os.mkdir(self._compilation_tempdir)
            except:
                print "Could not create compilation temp directory " + \
                      self._compilation_tempdir
                raise

        # ADMC targets must go in their own directories with appropriate names
        self._model_dir = "@"+self.name
        self._target_dir = os.path.join(self._compilation_tempdir,self._model_dir)
        # Make the target directory
        if not os.path.isdir(self._target_dir):
            try:
                assert not os.path.isfile(self._target_dir), \
                       "A file already exists with the same name"
                os.mkdir(self._target_dir)
            except:
                print "Could not creat target ADMC model directory " + \
                      self._target_dir
                raise


        """ An ADMC model has the following files:
        vfield.m -- contains code for the RHS of the vector field
        set.m -- a generic method that overload matlab's set method; only need to insert vfield name
        get.m -- a generic method that overloads matlab's get method; only need to insert appropriate parent name
        """

        # model.m, get.m, set.m, vfield.m are minimal files required. TO DO: EVENTS
        self._model_file = self.name+".m"
        self._ic_file = self.name+"_ics.m"
        self._param_file = self.name+"_params.m"
        self._set_file = "set.m"
        self._get_file = "get.m"
        self._vfield_file = "vfield.m"
        self._events_file = "events.m"

        self._vf_filename_ext = "_"+self._model_file[:-2]

        if not nobuild:
            self.makeLibSource()
        else:
            print "Build the library using the makeLib method, or in "
            print "stages using the makeLibSource and compileLib methods."
开发者ID:JuergenNeubauer,项目名称:PyDSTool-1,代码行数:95,代码来源:ADMC_ODEsystem.py

示例5: __init__

# 需要导入模块: from PyDSTool.Generator import ODEsystem [as 别名]
# 或者: from PyDSTool.Generator.ODEsystem import __init__ [as 别名]
    def __init__(self, kw):
        """Use the nobuild key to postpone building of the library, e.g. in
        order to provide additional build options to makeLibSource and
        compileLib methods or to make changes to the C code by hand.
        No build options can be specified otherwise."""

        # delete because not covered in ODEsystem
        nobuild = kw.pop('nobuild', False)
        ODEsystem.__init__(self, kw)
        self.diagnostics.outputStatsInfo = {
            'last_step': 'Predicted step size of the last accepted step (useful for a subsequent call to dop853).',
            'num_steps': 'Number of used steps.',
            'num_accept': 'Number of accepted steps.',
            'num_reject': 'Number of rejected steps.',
            'num_fcns': 'Number of function calls.',
            'errorStatus': 'Error status on completion.'
                        }
        self.diagnostics._errorcodes = {
             0 : 'Unrecognized error code returned (see stderr output)',
            -1 : 'input is not consistent',
            -2 : 'larger nmax is needed',
            2 : 'larger nmax or maxevtpts is probably needed (error raised by solout)',
            -3 : 'step size becomes too small',
            -4 : 'the problem is probably stiff (interrupted)',
            -8 : 'The solution exceeded a magbound (poor choice of initial step)'}
        self._solver = None
        algparams_def = {'poly_interp': False,
                        'init_step': 0,
                        'max_step': 0,
                        'rtol': [1e-9 for i in range(self.dimension)],
                        'atol': [1e-12 for i in range(self.dimension)],
                        'fac1': 0.2,
                        'fac2': 10.0,
                        'safety': 0.9,
                        'beta': 0.04,
                        'max_pts': 10000,
                        'refine': 0,
                        'maxbisect': [], # for events
                        'maxevtpts': 1000, # for events
                        'eventInt': [],  # set using setEventInterval only
                        'eventDelay': [], # set using setEventDelay only
                        'eventTol': [], # set using setEventTol only
                        'use_special': 0,
                        'specialtimes': [],
                        'check_aux': 1,
                        'extraspace': 100,
                        'verbose': 0,
                        'hasJac': 0,
                        'hasJacP': 0,
                        'magBound': 1e7,
                        'boundsCheckMaxSteps': 1000,
                        'checkBounds': self.checklevel
                        }
        for k, v in algparams_def.items():
            if k not in self.algparams:
                self.algparams[k] = v
        # verify that no additional keys are present in algparams, after
        # defaults are added above
        if len(self.algparams) != len(algparams_def):
            raise ValueError("Invalid keys present in algparams argument: " \
                     + str(remain(self.algparams.keys(),algparams_def.keys())))

        if self.haveMass():
            raise ValueError("Mass matrix declaration is incompatible "
                             "with Dopri853 integrator system specification")

        self._prepareEventSpecs()
        self._inputVarList = []
        self._inputTimeList = []

        if nobuild:
            print("Build the library using the makeLib method, or in ")
            print("stages using the makeLibSource and compileLib methods.")
        else:
            self.makeLib()
开发者ID:FedericoV,项目名称:pydstool,代码行数:77,代码来源:Dopri_ODEsystem.py


注:本文中的PyDSTool.Generator.ODEsystem.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。