예제 #1
0
 def update_defaults(cls, defaults):
     defaults.update({
         'lat_nx': H + 2,
         'lat_ny': H / 4,
         'grid': 'D2Q9',
         'tau_a': relaxation_time(visc1),
         'tau_b': relaxation_time(visc2),
         'tau_phi': 1.0,
         'force_implementation': 'edm',
         'kappa': 1e-4,
         'A': 32e-4,
         'Gamma': 25.0,
         'periodic_y': True,
         'bc_wall_grad_order': 1,
     })
예제 #2
0
 def update_defaults(cls, defaults):
     defaults.update({
         'lat_nx': H + 2,
         'lat_ny': H / 4,
         'grid': 'D2Q9',
         'tau_a': relaxation_time(visc1),
         'tau_b': relaxation_time(visc2),
         'tau_phi': 1.0,
         'force_implementation': 'edm',
         'kappa': 1e-4,
         'A': 32e-4,
         'Gamma': 25.0,
         'periodic_y': True,
         'bc_wall_grad_order': 1,
     })
예제 #3
0
 def update_defaults(cls, defaults):
     defaults.update({
         'lat_nx': H,
         'lat_ny': H + 2,
         'grid': 'D2Q9',
         'tau_a': relaxation_time(visc1),
         'tau_b': relaxation_time(visc2),
         'tau_phi': 1.0,
         # A wider interface helps with aliasing effects when decting the
         # position of the interface.
         'kappa': 0.04,
         'A': 0.02,
         # Keep this low to make the simulation reasonably fast.
         'Gamma': 0.8,
         'periodic_x': True,
         'bc_wall_grad_order': 1,
     })
예제 #4
0
 def update_defaults(cls, defaults):
     defaults.update({
         'lat_nx': H,
         'lat_ny': H + 2,
         'grid': 'D2Q9',
         'tau_a': relaxation_time(visc1),
         'tau_b': relaxation_time(visc2),
         'tau_phi': 1.0,
         # A wider interface helps with aliasing effects when decting the
         # position of the interface.
         'kappa': 0.04,
         'A': 0.02,
         # Keep this low to make the simulation reasonably fast.
         'Gamma': 0.8,
         'periodic_x': True,
         'bc_wall_grad_order': 1,
     })
예제 #5
0
 def update_defaults(cls, defaults):
     defaults.update({
         'lat_nx': H + 2,
         'lat_ny': H / 4,
         'grid': 'D2Q9',
         'visc': visc1,
         'tau_phi': relaxation_time(visc2),
         'force_implementation': 'edm',
         'G12': 1.2,
         'periodic_y': True,
     })
예제 #6
0
 def update_defaults(cls, defaults):
     defaults.update({
         'lat_nx': H + 2,
         'lat_ny': H / 4,
         'grid': 'D2Q9',
         'visc': visc1,
         'tau_phi': relaxation_time(visc2),
         'force_implementation': 'edm',
         'G12': 1.2,
         'periodic_y': True,
     })
예제 #7
0
 def update_context(self, ctx):
     super(LBFluidSim, self).update_context(ctx)
     if self.config.model == 'elbm':
         ctx['tau'] = self.config.visc / self.grid.cssq
     else:
         ctx['tau'] = sym.relaxation_time(self.config.visc)
     ctx['visc'] = self.config.visc
     ctx['model'] = self.config.model
     ctx['simtype'] = 'lbm'
     ctx['subgrid'] = self.config.subgrid
     ctx['smagorinsky_const'] = self.config.smagorinsky_const
     ctx['entropy_tolerance'] = 1e-6 if self.config.precision == 'single' else 1e-10
     ctx['alpha_output'] = self.alpha_output
     ctx['regularized'] = self.config.regularized
예제 #8
0
 def update_context(self, ctx):
     super(LBFluidSim, self).update_context(ctx)
     if self.config.model == 'elbm':
         ctx['tau'] = self.config.visc / self.grid.cssq
     else:
         ctx['tau'] = sym.relaxation_time(self.config.visc)
     ctx['visc'] = self.config.visc
     ctx['model'] = self.config.model
     ctx['simtype'] = 'lbm'
     ctx['subgrid'] = self.config.subgrid
     ctx['smagorinsky_const'] = self.config.smagorinsky_const
     ctx['entropy_tolerance'] = 1e-6 if self.config.precision == 'single' else 1e-10
     ctx['alpha_output'] = self.alpha_output
     ctx['regularized'] = self.config.regularized
예제 #9
0
 def update_context(self, ctx):
     super(LBBinaryFluidShanChen, self).update_context(ctx)
     ctx['simtype'] = 'shan-chen'
     ctx['sc_potential'] = self.config.sc_potential
     ctx['tau'] = sym.relaxation_time(self.config.visc)
     ctx['visc'] = self.config.visc
예제 #10
0
파일: tms.py 프로젝트: zmhou/sailfish
    def test_TMS(self):
        settings = {
            'debug_single_process': True,
            'quiet': True,
            'precision': 'double',
            'access_pattern': 'AB',
            'check_invalid_results_gpu': False,
            'check_invalid_results_host': False,
            'lat_nx': self.nx,
            'lat_ny': self.ny,
            'max_iters': 1,
            'visc': 1.0 / 12.0,
        }

        ctrl = LBSimulationController(Test2DSim, default_config=settings)
        ctrl.run(ignore_cmdline=True)
        runner = ctrl.master.runner
        dist = runner._debug_get_dist()

        rho_bb = 0.0
        ux_bb = 0.0
        uy_bb = 0.0

        for k, v in fi_start_2d.iteritems():
            if D2Q9.basis[k][1] == 1:
                v = fi_start_2d[D2Q9.idx_opposite[k]]

            rho_bb += v
            ux_bb += D2Q9.basis[k][0] * v
            uy_bb += D2Q9.basis[k][1] * v

        ux_bb /= rho_bb
        uy_bb /= rho_bb

        rho = 0.0
        ux = 0.0
        uy = 0.0

        cfg = LBConfig()
        cfg.incompressible = False
        cfg.minimize_roundoff = False
        eq = bgk_equilibrium(D2Q9, cfg).expression

        for k, v in fi_start_2d.iteritems():
            if D2Q9.basis[k][1] == 1:
                v = eq[k].evalf(subs={
                    'g0m0': rho_bb,
                    'g0m1x': ux_bb,
                    'g0m1y': uy_bb
                })

            rho += v
            ux += D2Q9.basis[k][0] * v
            uy += D2Q9.basis[k][1] * v

        ux /= rho
        uy /= rho

        print 'Target values are rho=%e, ux=%e, uy=%e' % (rho_bb, ux_bb, uy_bb)
        print 'Instantaneous values are rho=%e, ux=%e, uy=%e' % (rho, ux, uy)

        fneq = {}

        for k, v in fi_start_2d.iteritems():
            if D2Q9.basis[k][1] == 1:
                fneq[k] = (eq[k].evalf(subs={
                    'g0m0': rho_bb,
                    'g0m1x': ux_bb,
                    'g0m1y': uy_bb
                }) - eq[k].evalf(subs={
                    'g0m0': rho,
                    'g0m1x': ux,
                    'g0m1y': uy
                }))
            else:
                fneq[k] = v - eq[k].evalf(subs={
                    'g0m0': rho,
                    'g0m1x': ux,
                    'g0m1y': uy
                })

        tau = relaxation_time(1.0 / 12.0)
        omega = 1.0 / tau

        res = {}
        for k, v in fi_start_2d.iteritems():
            if D2Q9.basis[k][1] == 1:
                res[k] = ((1.0 - (omega - 1)) * eq[k].evalf(subs={
                    'g0m0': rho_bb,
                    'g0m1x': ux_bb,
                    'g0m1y': uy_bb
                }) + (omega - 1) * eq[k].evalf(subs={
                    'g0m0': rho,
                    'g0m1x': ux,
                    'g0m1y': uy
                }))
            else:
                res[k] = (v + omega * (eq[k].evalf(subs={
                    'g0m0': rho,
                    'g0m1x': ux,
                    'g0m1y': uy
                }) - v) + eq[k].evalf(subs={
                    'g0m0': rho_bb,
                    'g0m1x': ux_bb,
                    'g0m1y': uy_bb
                }) - eq[k].evalf(subs={
                    'g0m0': rho,
                    'g0m1x': ux,
                    'g0m1y': uy
                }))

        for k, v in res.iteritems():
            np.testing.assert_allclose(dist[k, 1, 16], np.float64(v))
예제 #11
0
 def modify_config(cls, config):
     config.tau_phi = sym.relaxation_time(config.visc)
예제 #12
0
 def modify_config(cls, config):
     config.tau_phi = sym.relaxation_time(config.visc)
예제 #13
0
 def update_context(self, ctx):
     super(LBTernaryFluidShanChen, self).update_context(ctx)
     ctx['simtype'] = 'shan-chen'
     ctx['sc_potential'] = self.config.sc_potential
     ctx['tau'] = sym.relaxation_time(self.config.visc)
     ctx['visc'] = self.config.visc
예제 #14
0
파일: tms.py 프로젝트: PokerN/sailfish
    def test_TMS(self):
        settings = {
            'debug_single_process': True,
            'quiet': True,
            'precision': 'double',
            'access_pattern': 'AB',
            'check_invalid_results_gpu': False,
            'check_invalid_results_host': False,
            'lat_nx': self.nx,
            'lat_ny': self.ny,
            'max_iters': 1,
            'visc': 1.0/12.0,
        }

        ctrl = LBSimulationController(Test2DSim, default_config=settings)
        ctrl.run(ignore_cmdline=True)
        runner = ctrl.master.runner
        dist = runner._debug_get_dist()

        rho_bb = 0.0
        ux_bb = 0.0
        uy_bb = 0.0

        for k, v in fi_start_2d.iteritems():
            if D2Q9.basis[k][1] == 1:
                v = fi_start_2d[D2Q9.idx_opposite[k]]

            rho_bb += v
            ux_bb += D2Q9.basis[k][0] * v
            uy_bb += D2Q9.basis[k][1] * v

        ux_bb /= rho_bb
        uy_bb /= rho_bb

        rho = 0.0
        ux = 0.0
        uy = 0.0

        cfg = LBConfig()
        cfg.incompressible = False
        cfg.minimize_roundoff = False
        eq = bgk_equilibrium(D2Q9, cfg).expression

        for k, v in fi_start_2d.iteritems():
            if D2Q9.basis[k][1] == 1:
                v = eq[k].evalf(subs={'g0m0': rho_bb, 'g0m1x': ux_bb,
                                      'g0m1y': uy_bb})

            rho += v
            ux += D2Q9.basis[k][0] * v
            uy += D2Q9.basis[k][1] * v

        ux /= rho
        uy /= rho

        print 'Target values are rho=%e, ux=%e, uy=%e' % (rho_bb, ux_bb, uy_bb)
        print 'Instantaneous values are rho=%e, ux=%e, uy=%e' % (rho, ux, uy)

        fneq = {}

        for k, v in fi_start_2d.iteritems():
            if D2Q9.basis[k][1] == 1:
                fneq[k] = (eq[k].evalf(subs={'g0m0': rho_bb, 'g0m1x': ux_bb, 'g0m1y': uy_bb}) -
                           eq[k].evalf(subs={'g0m0': rho, 'g0m1x': ux, 'g0m1y': uy}))
            else:
                fneq[k] = v - eq[k].evalf(subs={'g0m0': rho, 'g0m1x': ux, 'g0m1y': uy})

        tau = relaxation_time(1.0/12.0)
        omega = 1.0 / tau

        res = {}
        for k, v in fi_start_2d.iteritems():
            if D2Q9.basis[k][1] == 1:
                res[k] = ((1.0 - (omega - 1)) *
                          eq[k].evalf(subs={'g0m0': rho_bb, 'g0m1x': ux_bb, 'g0m1y': uy_bb}) +
                          (omega - 1) * eq[k].evalf(subs={'g0m0': rho, 'g0m1x': ux, 'g0m1y': uy}))
            else:
                res[k] = (v + omega * (eq[k].evalf(subs={'g0m0': rho, 'g0m1x': ux, 'g0m1y': uy}) - v) +
                          eq[k].evalf(subs={'g0m0': rho_bb, 'g0m1x': ux_bb, 'g0m1y': uy_bb}) -
                          eq[k].evalf(subs={'g0m0': rho, 'g0m1x': ux, 'g0m1y': uy}))

        for k, v in res.iteritems():
            np.testing.assert_allclose(dist[k,1,16], np.float64(v))