|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
求问,为什么第三方库内定义的函数都直接pass,那是如何实现它的功能的呢?
这个是cantera模块的一个ReactorNet类,其中类方法只有一个注释和pass,我想改变其中的step,但完全看不懂它是如何实现的
- # encoding: utf-8
- # module cantera._cantera
- # from C:\Users\Administrator\PycharmProjects\untitled\venv\lib\site-packages\cantera\_cantera.cp37-win_amd64.pyd
- # by generator 1.145
- # no doc
- # imports
- import builtins as __builtins__ # <module 'builtins' (built-in)>
- import numpy as np # C:\Users\Administrator\PycharmProjects\untitled\venv\lib\site-packages\numpy\__init__.py
- import math as math # <module 'math' (built-in)>
- import sys as sys # <module 'sys' (built-in)>
- import os as os # C:\Program Files\Python37\lib\os.py
- import warnings as warnings # C:\Program Files\Python37\lib\warnings.py
- import weakref as weakref # C:\Program Files\Python37\lib\weakref.py
- import numbers as _numbers # C:\Program Files\Python37\lib\numbers.py
- import cantera.interrupts as interrupts # C:\Users\Administrator\PycharmProjects\untitled\venv\lib\site-packages\cantera\interrupts.py
- from .object import object
- class ReactorNet(object):
- """
- ReactorNet(reactors=())
-
- Networks of reactors. ReactorNet objects are used to simultaneously
- advance the state of one or more coupled reactors.
-
- Example:
-
- >>> r1 = Reactor(gas1)
- >>> r2 = Reactor(gas2)
- >>> <... install walls, inlets, outlets, etc...>
-
- >>> reactor_network = ReactorNet([r1, r2])
- >>> reactor_network.advance(time)
- """
- def add_reactor(self, Reactor_r): # real signature unknown; restored from __doc__
- """
- ReactorNet.add_reactor(self, Reactor r)
- Add a reactor to the network.
- """
- pass
- def advance(self, double_t): # real signature unknown; restored from __doc__
- """
- ReactorNet.advance(self, double t)
-
- Advance the state of the reactor network in time from the current
- time to time *t* [s], taking as many integrator timesteps as necessary.
- """
- pass
- def advance_to_steady_state(self, int_max_steps=10000, double_residual_threshold=0., double_atol=0., bool_return_residuals=False): # real signature unknown; restored from __doc__
- """
- ReactorNet.advance_to_steady_state(self, int max_steps=10000, double residual_threshold=0., double atol=0., bool return_residuals=False)
-
- Advance the reactor network in time until steady state is reached.
-
- The steady state is defined by requiring that the state of the system
- only changes below a certain threshold. The residual is computed using
- feature scaling:
-
- .. math:: r = \left| \frac{x(t + \Delta t) - x(t)}{\text{max}(x) + \text{atol}} \right| \cdot \frac{1}{\sqrt{n_x}}
-
- :param max_steps:
- Maximum number of steps to be taken
- :param residual_threshold:
- Threshold below which the feature-scaled residual r should drop such
- that the network is defines as steady state. By default,
- residual_threshold is 10 times the solver rtol.
- :param atol:
- The smallest expected value of interest. Used for feature scaling.
- By default, this atol is identical to the solver atol.
- :param return_residuals:
- If set to `True`, this function returns the residual time series
- as a vector with length `max_steps`.
- """
- pass
- def component_name(self, int_i): # real signature unknown; restored from __doc__
- """
- ReactorNet.component_name(self, int i)
-
- Return the name of the i-th component of the global state vector. The
- name returned includes both the name of the reactor and the specific
- component, e.g. `'reactor1: CH4'`.
- """
- pass
- def get_state(self): # real signature unknown; restored from __doc__
- """
- ReactorNet.get_state(self)
-
- Get the combined state vector of the reactor network.
-
- The combined state vector consists of the concatenated state vectors of
- all entities contained.
- """
- pass
- def reinitialize(self): # real signature unknown; restored from __doc__
- """
- ReactorNet.reinitialize(self)
-
- Reinitialize the integrator after making changing to the state of the
- system. Changes to Reactor contents will automatically trigger
- reinitialization.
- """
- pass
- def sensitivities(self): # real signature unknown; restored from __doc__
- """
- ReactorNet.sensitivities(self)
-
- Returns the sensitivities of all of the solution variables with respect
- to all of the registered parameters. The normalized sensitivity
- coefficient :math:`S_{ki}` of the solution variable :math:`y_k` with
- respect to sensitivity parameter :math:`p_i` is defined as:
-
- .. math:: S_{ki} = \frac{p_i}{y_k} \frac{\partial y_k}{\partial p_i}
-
- For reaction sensitivities, the parameter is a multiplier on the forward
- rate constant (and implicitly on the reverse rate constant for
- reversible reactions).
-
- The sensitivities are returned in an array with dimensions *(n_vars,
- n_sensitivity_params)*, unless no timesteps have been taken, in which
- case the shape is *(0, n_sensitivity_params)*. The order of the
- variables (i.e., rows) is:
-
- `Reactor` or `IdealGasReactor`:
-
- - 0 - mass
- - 1 - volume
- - 2 - internal energy or temperature
- - 3+ - mass fractions of the species
-
- `ConstPressureReactor` or `IdealGasConstPressureReactor`:
-
- - 0 - mass
- - 1 - enthalpy or temperature
- - 2+ - mass fractions of the species
- """
- pass
- def sensitivity(self, component, int_p, int_r=0): # real signature unknown; restored from __doc__
- """
- ReactorNet.sensitivity(self, component, int p, int r=0)
-
- Returns the sensitivity of the solution variable *component* in
- reactor *r* with respect to the parameter *p*. *component* can be a
- string or an integer. See `component_index` and `sensitivities` to
- determine the integer index for the variables and the definition of the
- resulting sensitivity coefficient. If it is not given, *r* defaults to
- the first reactor. Returns an empty array until the first time step is
- taken.
- """
- pass
- def sensitivity_parameter_name(self, int_p): # real signature unknown; restored from __doc__
- """
- ReactorNet.sensitivity_parameter_name(self, int p)
-
- Name of the sensitivity parameter with index *p*.
- """
- pass
- def set_initial_time(self, double_t): # real signature unknown; restored from __doc__
- """
- ReactorNet.set_initial_time(self, double t)
-
- Set the initial time. Restarts integration from this time using the
- current state as the initial condition. Default: 0.0 s.
- """
- pass
- def set_max_time_step(self, double_t): # real signature unknown; restored from __doc__
- """
- ReactorNet.set_max_time_step(self, double t)
-
- Set the maximum time step *t* [s] that the integrator is allowed
- to use.
- """
- pass
- def step(self): # real signature unknown; restored from __doc__
- """
- ReactorNet.step(self)
-
- Take a single internal time step. The time after taking the step is
- returned.
- """
- pass
- def __copy__(self): # real signature unknown; restored from __doc__
- """ ReactorNet.__copy__(self) """
- pass
- def __init__(self, reactors=()): # real signature unknown; restored from __doc__
- pass
- @staticmethod # known case of __new__
- def __new__(*args, **kwargs): # real signature unknown
- """ Create and return a new object. See help(type) for accurate signature. """
- pass
- def __reduce__(self): # real signature unknown; restored from __doc__
- """ ReactorNet.__reduce__(self) """
- pass
- atol = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
- """
- The absolute error tolerance used while integrating the reactor
- equations.
- """
- atol_sensitivity = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
- """
- The absolute error tolerance for sensitivity analysis.
- """
- max_err_test_fails = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
- """
- The maximum number of error test failures permitted by the CVODES
- integrator in a single time step.
- """
- n_sensitivity_params = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
- """
- The number of registered sensitivity parameters.
- """
- n_vars = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
- """
- The number of state variables in the system. This is the sum of the
- number of variables for each `Reactor` and `Wall` in the system.
- Equal to:
- `Reactor` and `IdealGasReactor`: `n_species` + 3 (mass, volume,
- internal energy or temperature).
- `ConstPressureReactor` and `IdealGasConstPressureReactor`:
- `n_species` + 2 (mass, enthalpy or temperature).
- `Wall`: number of surface species
- """
- rtol = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
- """
- The relative error tolerance used while integrating the reactor
- equations.
- """
- rtol_sensitivity = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
- """
- The relative error tolerance for sensitivity analysis.
- """
- time = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
- """The current time [s]."""
- verbose = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
- """
- If *True*, verbose debug information will be printed during
- integration. The default is *False*.
- """
复制代码 |
|