Exemplo n.º 1
0
def DoubleLegendre(name, N, interval=(-1, 1), dealias=1):
    N0 = int(N // 2)
    N1 = N - N0
    L = interval[1] - interval[0]
    int0 = (interval[0], interval[0] + L / 2)
    int1 = (interval[0] + L / 2, interval[1])
    b0 = de.Legendre('b0', N0, interval=int0, dealias=dealias)
    b1 = de.Legendre('b1', N1, interval=int1, dealias=dealias)
    return de.Compound(name, (b0, b1), dealias=dealias)
η = c1 / c4
print(c4, c1, η)
Lz = 1.25

logger.info(
    "Target atmosphere has ln_Teff = {} and τ0 = {:g} for ε = {:g}".format(
        ln_Teff, τ0, ε))

tau_0_BB14 = 4e-4 * np.array([1e4, 1e5, 1e6, 1e7]) * 5
F_over_cE_BB14 = 1 / 4 * (np.array([26600, 16300, 9300, 5200]) / 38968)**4
Q_BB14 = tau_0_BB14 * F_over_cE_BB14

# Domain
z_basis = de.Legendre('z',
                      nz,
                      interval=(0, Lz),
                      dealias=2,
                      tau_after_pre=False)
domain = de.Domain([z_basis], np.float64, comm=MPI.COMM_SELF)

# Problem
problem = de.NLBVP(domain, variables=['ln_T', 'ln_rho'], ncc_cutoff=ncc_cutoff)
problem.parameters['a'] = a
problem.parameters['b'] = b
problem.parameters['g'] = g = (m + 1)
problem.parameters['Lz'] = Lz
problem.parameters['gamma'] = gamma
problem.parameters['ε'] = ε
problem.parameters['η'] = η
problem.parameters['Q'] = Q
problem.parameters['F'] = F
Exemplo n.º 3
0
# Load background
atmosphere_file = h5py.File('./atmosphere.h5', 'r')
z_atmosphere = atmosphere_file['z'][:]
ln_T = atmosphere_file['ln_T'][:]
ln_rho = atmosphere_file['ln_rho'][:]
brunt2 = atmosphere_file['brunt_squared'][:]
ω_ac2 = atmosphere_file['ω_ac_squared'][:]
c_s2 = atmosphere_file['c_s_squared'][:]
nz = atmosphere_file['nz'][()]
Lz = atmosphere_file['Lz'][()]
gamma = atmosphere_file['gamma'][()]
atmosphere_file.close()

# Problem
gamma = 5/3
z_basis = de.Legendre('z', nz_waves, interval=(0, Lz), tau_after_pre=False)
domain_EVP = de.Domain([z_basis], comm=MPI.COMM_SELF)
waves = de.EVP(domain_EVP, ['u','w','T1','ln_rho1', 'w_z'], eigenvalue='omega', ncc_cutoff=ncc_cutoff)
n_var = 5
T0 = domain_EVP.new_field()
T0_z = domain_EVP.new_field()
ln_rho0 = domain_EVP.new_field()
del_ln_rho0 = domain_EVP.new_field()

# Resample background
scale = nz/nz_waves
logger.info("data nz ({:d}) is {} times larger than wave nz ({:d})".format(nz,scale,nz_waves))
T0.set_scales(scale)
T0_z.set_scales(scale)
ln_rho0.set_scales(scale)
del_ln_rho0.set_scales(scale)