예제 #1
0
    def get_stability(self, state, markers1=None, markers2=None):
        dico = deepcopy(self.get_dictionary())
        param = self.get_required_param()
        for p in param:
            dico['parameters'][p] = state[p]
        scheme = pylbm.Scheme(dico)
        stab = pylbm.Stability(scheme)

        consm0 = [0.] * len(stab.consm)
        for k, moment in enumerate(stab.consm):
            consm0[k] = state.get(moment, 0.)

        n_wv = 1024
        v_xi, eigs = stab.eigenvalues(consm0, n_wv)
        nx = v_xi.shape[1]

        if markers1 is not None:
            pos0 = np.empty((nx * stab.nvtot, 2))
            for k in range(stab.nvtot):
                pos0[nx * k:nx * (k + 1), 0] = np.real(eigs[:, k])
                pos0[nx * k:nx * (k + 1), 1] = np.imag(eigs[:, k])
            markers1.set_offsets(pos0)

        if markers2 is not None:
            pos1 = np.empty((nx * stab.nvtot, 2))
            for k in range(stab.nvtot):
                pos1[nx * k:nx * (k + 1), 0] = np.max(v_xi, axis=0)
                pos1[nx * k:nx * (k + 1), 1] = np.abs(eigs[:, k])
            markers2.set_offsets(pos1)

        return stab
예제 #2
0
def scheme_constructor(ux, uy, s_mu, s_eta):
    rhoo = 1.
    la = 1.
    s3 = s_mu
    s4 = s3
    s5 = s4
    s6 = s4
    s7 = s_eta
    s8 = s7
    s = [0., 0., 0., s3, s4, s5, s6, s7, s8]
    dummy = 1. / (LA**2 * rhoo)
    qx2 = dummy * qx**2
    qy2 = dummy * qy**2
    q2 = qx2 + qy2
    qxy = dummy * qx * qy

    dico = {
        'dim':
        2,
        'scheme_velocity':
        la,
        'parameters': {
            LA: la
        },
        'schemes': [
            {
                'velocities':
                list(range(9)),
                'conserved_moments': [rho, qx, qy],
                'polynomials': [
                    1, LA * X, LA * Y, 3 * (X**2 + Y**2) - 4,
                    0.5 * (9 * (X**2 + Y**2)**2 - 21 * (X**2 + Y**2) + 8),
                    3 * X * (X**2 + Y**2) - 5 * X,
                    3 * Y * (X**2 + Y**2) - 5 * Y, X**2 - Y**2, X * Y
                ],
                'relaxation_parameters':
                s,
                'equilibrium': [
                    rho, qx, qy, -2 * rho + 3 * q2, rho + 1.5 * q2, -qx / LA,
                    -qy / LA, qx2 - qy2, qxy
                ],
            },
        ],
        'stability': {
            'linearization': {
                rho: rhoo,
                qx: ux,
                qy: uy
            },
            'test_maximum_principle': False,
            'test_L2_stability': False,
        },
    }
    return pylbm.Scheme(dico)
예제 #3
0
    def __call__(self, config, extra_config=None):
        scheme = pylbm.Scheme(config)
        stab = pylbm.Stability(scheme)
        n_wv = 1024

        for state in self.states:
            consm0 = [0.] * len(stab.consm)
            for k, moment in enumerate(stab.consm):
                consm0[k] = state.get(moment, 0.)

            stab.eigenvalues(consm0, n_wv, extra_config)

            if not stab.is_stable_l2:
                return False
        return True
예제 #4
0
def scheme_constructor(ux, sq, sE):
    dico = {
        'dim':
        1,
        'scheme_velocity':
        1.,
        'schemes': [
            {
                'velocities': list(range(3)),
                'conserved_moments': u,
                'polynomials': [1, X, X**2],
                'equilibrium': [u, ux * u, (2 * ux**2 + 1) / 3 * u],
                'relaxation_parameters': [0., sq, sE],
            },
        ],
        'stability': {
            'test_maximum_principle': False,
            'test_L2_stability': False,
        },
    }
    return pylbm.Scheme(dico)
예제 #5
0
# pylint: disable=invalid-name

U, X = sp.symbols('u, X')
LA, C, SIGMA = sp.symbols('lambda, c, sigma', constants=True)

scheme_cfg = {
    'dim':
    1,
    'scheme_velocity':
    LA,
    'schemes': [
        {
            'velocities': [1, 2],
            'conserved_moments': U,
            'polynomials': [1, X],
            'equilibrium': [U, C * U],
            'relaxation_parameters': [0, 1 / (0.5 + SIGMA)],
        },
    ],
    'parameters': {
        LA: 1.,
        C: 0.1,
        SIGMA: 1. / 1.9 - .5,
    },
}

scheme = pylbm.Scheme(scheme_cfg)
eq_pde = pylbm.EquivalentEquation(scheme)

print(eq_pde)
예제 #6
0
# Authors:
#     Loic Gouarin <*****@*****.**>
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause

"""
Example of a D1Q3 for the wave equation
"""
import sympy as sp
import pylbm
u, v, X = sp.symbols('u, v, X')

c = 0.5
d = {
  'dim': 1,
  'scheme_velocity': 1.,
  'schemes': [{
    'velocities': [0, 1, 2],
    'conserved_moments': [u, v],
    'polynomials': [1, X, 0.5*X**2],
    'equilibrium': [u, v, .5*c**2*u],
    'relaxation_parameters': [0., 0., 1.9],
    },
  ],
}
s = pylbm.Scheme(d)
print(s)
예제 #7
0
 def get_information(self):
     scheme = pylbm.Scheme(self.get_dictionary())
     return scheme
예제 #8
0
 def get_eqpde(self):
     scheme = pylbm.Scheme(self.get_dictionary())
     eqpde = pylbm.EquivalentEquation(scheme)
     return eqpde
예제 #9
0
            'polynomials': [1, X, Y, X**2 - Y**2],
            'relaxation_parameters': [0, S_1, S_1, S_2],
            'equilibrium': [U, CX * U, CY * U, (CX**2 - CY**2) * U],
        },
    ],
    'parameters': {
        LA: la,
        S_1: s_1,
        S_2: s_2,
        CX: c_x,
        CY: c_y,
    },
    'relative_velocity': [CX, CY],
}

scheme = pylbm.Scheme(dico)
stab = pylbm.Stability(scheme)
stab.visualize({
    'parameters': {
        CX: {
            'range': [0, 1],
            'init': c_x,
            'step': 0.01,
        },
        CY: {
            'range': [0, 1],
            'init': c_y,
            'step': 0.01,
        },
        S_1: {
            'name': r"$s_1$",
예제 #10
0
import sympy as sp
import pylbm

# pylint: disable=invalid-name

U, X = sp.symbols('u, X')
LA, SIGMA = sp.symbols('lambda, sigma', constants=True)

scheme_cfg = {
    'dim': 1,
    'scheme_velocity': LA,
    'schemes': [
        {
            'velocities': [1, 2],
            'conserved_moments': U,
            'polynomials': [1, X],
            'equilibrium': [U, U**2/2],
            'relaxation_parameters': [0, 1/(0.5+SIGMA)],
        },
    ],
    'parameters': {
        LA: 1.,
        SIGMA: 1./1.9-.5,
    },
}

scheme = pylbm.Scheme(scheme_cfg, formal=True)
eq_pde = pylbm.EquivalentEquation(scheme)

print(eq_pde)
예제 #11
0
            'polynomials': [1, X],
            'relaxation_parameters': [0, S_P],
            'equilibrium':
            [E, GAMMA * E * Q / RHO - (GAMMA - 1) / 2 * Q**3 / RHO**2],
        },
    ],
    'parameters': {
        LA: la,
        S_RHO: s_rho,
        S_U: s_u,
        S_P: s_p,
        GAMMA: gamma,
    },
}

scheme = pylbm.Scheme(dico, formal=True)
stab = pylbm.Stability(scheme)

# linearization around a state
rhoo = 1
uo = 0.5
po = 1
qo = rhoo * uo
Eo = .5 * rhoo * uo**2 + po / (gamma - 1.)

stab.visualize({
    'linearization': {
        RHO: rhoo,
        Q: qo,
        E: Eo,
    },