示例#1
0
    def read_params(self, vars):
        # Get the physical location of each solution point
        vars.update(self.cfg.section_values('non-dim', np.float64))
        vars.update(self.cfg.section_values('mesh', np.float64))

        # Evaluate the ICs from the config file
        self._rhoini = npeval(self.cfg.lookupexpr(self.name, 'rho'), vars)
        self._uxini = npeval(self.cfg.lookupexpr(self.name, 'ux'), vars)
        self._uyini = npeval(self.cfg.lookupexpr(self.name, 'uy'), vars)
        self._uzini = npeval(self.cfg.lookupexpr(self.name, 'uz'), vars)
        self._Tini = npeval(self.cfg.lookupexpr(self.name, 'T'), vars)
示例#2
0
    def apply_init_vals(self, scal_upts_full, Nq, Ne, xsol, **kwargs):
        vars = self._vars

        # Get the physical location of each solution point
        vars.update(self.cfg.section_values('non-dim', np.float64))
        vars.update(self.cfg.section_values('mesh', np.float64))

        # Get the physical location of each solution point
        coords = xsol
        vars.update(dict({'x': coords}))

        # Properties on the left
        #rhol = self.cfg.lookupfloat(self.name,'rho-left')
        #Tl = self.cfg.lookupfloat(self.name,'T-left')
        #ulx = self.cfg.lookupordefault(self.name,'ux-left', 0.)
        rhol, Tl, ulx = map(lambda v: npeval(self.cfg.lookupexpr(self.name,v),vars), \
                ('rho-left', 'T-left', 'ux-left'))
        #Ml = self.maxwellian(rhol, ulx, 0., 0., Tl)

        # Properties on the right
        #rhor = self.cfg.lookupfloat(self.name,'rho-right')
        #Tr = self.cfg.lookupfloat(self.name,'T-right')
        #urx = self.cfg.lookupordefault(self.name,'ux-right', 0.)
        rhor, Tr, urx = map(lambda v: npeval(self.cfg.lookupexpr(self.name, v),vars), \
                ('rho-right', 'T-right', 'ux-right'))

        #Mr = self.maxwellian(rhor, urx, 0., 0., Tr)

        def isf(data):
            return isinstance(data, (self.cfg.dtype, float))

        def make_shape(ds):
            return np.full((Nq, Ne), ds) if isf(ds) else ds

        rhol, Tl, ulx, rhor, Tr, urx = map(make_shape,
                                           [rhol, Tl, ulx, rhor, Tr, urx])

        xMid = self.cfg.lookupfloat(self.name, 'xMid')

        for upt, elem in ndrange(Nq, Ne):
            if coords[upt, elem] <= xMid:
                Ml = self.maxwellian(rhol[upt, elem], ulx[upt, elem], 0., 0.,
                                     Tl[upt, elem])
                scal_upts_full[upt, elem, :] = Ml
            else:
                Mr = self.maxwellian(rhor[upt, elem], urx[upt, elem], 0., 0.,
                                     Tr[upt, elem])
                scal_upts_full[upt, elem, :] = Mr
示例#3
0
    def apply_init_vals(self, p, scal_upts_full, Nq, Ne, xsol):
        assert p >= 0 and p < self._nspcs, "Should be in range"
        m = self.vm.masses()[p]

        vars = self._vars

        # Get the physical location of each solution point
        coords = xsol
        vars.update(dict({'x': coords}))

        # Evaluate the ICs from the config file
        ndenini = npeval(self.cfg.lookupexpr(self.name, 'nden' + str(p + 1)),
                         vars)
        ndenini /= self.vm.n0()
        uxini = npeval(self.cfg.lookupexpr(self.name, 'ux'),
                       vars) / self.vm.u0()
        uyini = npeval(self.cfg.lookupexpr(self.name, 'uy'),
                       vars) / self.vm.u0()
        uzini = npeval(self.cfg.lookupexpr(self.name, 'uz'),
                       vars) / self.vm.u0()
        Tini = npeval(self.cfg.lookupexpr(self.name, 'T'), vars) / self.vm.T0()

        def isf(data):
            return isinstance(data, self.cfg.dtype)

        if all(map(isf, [ndenini, uxini, uyini, uzini, Tini])):
            mxwl = self.maxwellian(m, ndenini, uxini, uyini, uzini, Tini)
            for j in range(self.vm.vsize()):
                scal_upts_full[:, :, j] = mxwl[j]
        else:

            def shape(ds):
                if isf(ds): return np.full((Nq, Ne), ds)
                else: return ds

            ndenini, uxini, uyini, uzini, Tini = map(
                shape, [ndenini, uxini, uyini, uzini, Tini])

            for quad, elem in ndrange(Nq, Ne):
                scal_upts_full[quad, elem, :] = self.maxwellian(
                    m, ndenini[quad, elem], uxini[quad, elem],
                    uyini[quad, elem], uzini[quad, elem], Tini[quad, elem])
示例#4
0
 def expr(self):
     expr = self.cfg.lookupexpr(msect, 'expr')
     xmesh = np.sort(
         np.array(npeval(expr, {}), dtype=self.cfg.dtype).ravel())
     assert len(xmesh) >= 2, "Need atleast two points to define the mesh"
     return xmesh