Esempio n. 1
0
    def __init__(self, **kwargs):
        PrmDictBase.__init__(self)
        self.physical_prm = {
            'f': 0,
            'I': 1,
            'bc_0': 0,
            'bc_L': 0,
            'L': 1,
            'c': 1,
            }
        self.numerical_prm = {
            'dt': 0,
            'safety_factor': 1.0,  # multiplies dt
            'tstop': 1,
            'n': 10,
            'user_action': lambda s: None,  # callable with one arg.
            'scheme_coding': 'scalar',  # alt: 'vectorized'
            }
        # bring variables into existence (with dummy values):
        self.x  = zeros(1)         # grid points
        self.up = zeros(1)         # sol. at new time level
        self.u  = self.up.copy()   # prevous time level
        self.um = self.up.copy()   # two time levels behind

        self._prm_list = [self.physical_prm, self.numerical_prm]
        self._type_check = {'n': int, 'tstop': (int,float),
                            'dt': (int,float),
                            'safety_factor': (int,float)}
        self.user_prm = None   # no extra user parameters
        self.set(**kwargs)     # assign parameters (if any kwargs)
        self.finished = False  # enables stopping simulations
Esempio n. 2
0
    def __init__(self, **kwargs):
        PrmDictBase.__init__(self)
        self.physical_prm = {
            'f': 0,
            'I': 1,
            'bc_0': 0,
            'bc_L': 0,
            'L': 1,
            'c': 1,
        }
        self.numerical_prm = {
            'dt': 0,
            'safety_factor': 1.0,  # multiplies dt
            'tstop': 1,
            'n': 10,
            'user_action': lambda s: None,  # callable with one arg.
            'scheme_coding': 'scalar',  # alt: 'vectorized'
        }
        # bring variables into existence (with dummy values):
        self.x = zeros(1)  # grid points
        self.up = zeros(1)  # sol. at new time level
        self.u = self.up.copy()  # prevous time level
        self.um = self.up.copy()  # two time levels behind

        self._prm_list = [self.physical_prm, self.numerical_prm]
        self._type_check = {
            'n': (int, float),
            'tstop': (int, float),
            'dt': (int, float),
            'safety_factor': (int, float)
        }
        self.user_prm = None  # no extra user parameters
        self.set(**kwargs)  # assign parameters (if any kwargs)
        self.finished = False  # enables stopping simulations
Esempio n. 3
0
    def __init__(self, **kwargs):
        PrmDictBase.__init__(self)
        # register parameters in dictionaries:
        self.physical_prm = {'density': 1.0, 'Cp': 1.0, 'k': 1.0, 'L': 1.0}
        self.numerical_prm = {'n': 10, 'dt': 0.1, 'tstop': 3}

        # attach dictionaries to base class list (required):
        self._prm_list = [self.physical_prm, self.numerical_prm]

        # specify parameters to be type checked when set:
        # (this stopped working...)
        #self._type_check.update({'n': True, 'dt': (float,),
        #      'k': lambda k: isinstance(int,float) and k>0})

        # disallow arbitrary meta data
        self.user_prm = None  # set to {} if meta data are allowed

        # initialize parameters according to keyword arguments:
        self.set(**kwargs)
Esempio n. 4
0
    def __init__(self, **kwargs):
        PrmDictBase.__init__(self)
        # register parameters in dictionaries:
        self.physical_prm = {'density': 1.0, 'Cp': 1.0,
                                   'k': 1.0, 'L': 1.0}
        self.numerical_prm =  {'n': 10, 'dt': 0.1, 'tstop': 3}

        # attach dictionaries to base class list (required):
        self._prm_list = [self.physical_prm, self.numerical_prm]

        # specify parameters to be type checked when set:
        # (this stopped working...)
        #self._type_check.update({'n': True, 'dt': (float,),
        #      'k': lambda k: isinstance(int,float) and k>0})

        # disallow arbitrary meta data
        self.user_prm = None # set to {} if meta data are allowed

        # initialize parameters according to keyword arguments:
        self.set(**kwargs)