-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import pylbo.gimli as gimli | ||
import sympy as sp | ||
import filecmp | ||
|
||
def test_variables(): | ||
obj = gimli.Variables() | ||
keychain = obj.__dict__.keys() | ||
for key in [ | ||
'x', 'y', 'z', | ||
'rho0', 'T0', 'B0sq','k2', 'k3', | ||
'rhoc', 'Tc', 'B2c', 'B3c', 'v2c', 'v3c', 'pc', | ||
'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', | ||
'alpha', 'beta', 'delta', 'theta', 'tau', 'lamda', 'nu', | ||
'r0', 'rc', 'rj', 'Bth0', 'Bz0', 'V', 'j0', 'g' | ||
]: | ||
assert key in keychain | ||
assert isinstance(obj.__dict__[key], sp.Symbol) | ||
assert 'fkey' in keychain | ||
assert isinstance(obj.__dict__['fkey'], dict) | ||
|
||
|
||
def test_equilibrium(): | ||
var = gimli.Variables() | ||
obj = gimli.Equilibrium(var, var.rhoc, 0, 0, var.Tc) | ||
keychain = obj.__dict__.keys() | ||
for key in [ | ||
'variables', 'rho0', 'v02', 'v03', 'T0', 'B02', 'B03', '_dict_phys' | ||
]: | ||
assert key in keychain | ||
assert isinstance(obj.get_physics(), dict) | ||
assert isinstance(obj.get_dependencies(), dict) | ||
|
||
|
||
def test_legolas_userfile(tmpdir, mod_usr): | ||
config = { | ||
"geometry": "Cartesian", | ||
"x_start": -1, | ||
"x_end": 1, | ||
"gridpoints": 51, | ||
"parameters": { | ||
"k2": 1, | ||
"k3": 0, | ||
"cte_rho0": 1, | ||
"cte_T0": 0.5, | ||
}, | ||
"equilibrium_type": "user_defined", | ||
"physics_type": "mhd", | ||
"logging_level": 1 | ||
} | ||
var = gimli.Variables() | ||
eq = gimli.Equilibrium(var, var.rhoc, 0, 0, var.Tc) | ||
obj = gimli.Legolas(eq, config) | ||
obj.user_module(loc=tmpdir) | ||
assert filecmp.cmp((tmpdir / 'smod_user_defined.f08').resolve(), mod_usr, shallow=False) | ||
|
||
|
||
def test_amrvac_preparation(tmpdir, datv211_harris, vacv211_harris): | ||
config = { | ||
"datfile": datv211_harris, | ||
"physics_type": "mhd", | ||
"ev_guess": [0.01636j, 0.4323-6.391e-5*1j, -0.4323-6.391e-5*1j], | ||
"ev_time": 0, | ||
"percentage": 0.01, | ||
"quantity": "B02" | ||
} | ||
amrvac = gimli.Amrvac(config) | ||
amrvac.prepare_legolas_data(loc=tmpdir) | ||
assert filecmp.cmp((tmpdir / 'v2.1.1_harris.ldat').resolve(), vacv211_harris, shallow=False) |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
!> Submodule for user-defined equilibria. | ||
!! Generated with GIMLI v0.4. | ||
submodule (mod_equilibrium) smod_user_defined | ||
use mod_logging, only: logger | ||
use mod_equilibrium_params, only: cte_rho0, cte_T0 | ||
implicit none | ||
|
||
contains | ||
|
||
module procedure user_defined_eq | ||
if(settings%equilibrium%use_defaults) then | ||
call logger%error("No default values specified.") | ||
end if | ||
|
||
call background%set_density_funcs(rho0_func=rho0, drho0_func=drho0) | ||
call background%set_velocity_2_funcs(v02_func=v02, dv02_func=dv02, ddv02_func=ddv02) | ||
call background%set_velocity_3_funcs(v03_func=v03, dv03_func=dv03, ddv03_func=ddv03) | ||
call background%set_temperature_funcs(T0_func=T0, dT0_func=dT0, ddT0_func=ddT0) | ||
call background%set_magnetic_2_funcs(B02_func=B02, dB02_func=dB02, ddB02_func=ddB02) | ||
call background%set_magnetic_3_funcs(B03_func=B03, dB03_func=dB03, ddB03_func=ddB03) | ||
|
||
end procedure user_defined_eq | ||
|
||
real(dp) function rho0() | ||
rho0 = cte_rho0 | ||
end function rho0 | ||
|
||
real(dp) function drho0() | ||
drho0 = 0.0d0 | ||
end function drho0 | ||
|
||
real(dp) function v02() | ||
v02 = 0.0d0 | ||
end function v02 | ||
|
||
real(dp) function dv02() | ||
dv02 = 0.0d0 | ||
end function dv02 | ||
|
||
real(dp) function ddv02() | ||
ddv02 = 0.0d0 | ||
end function ddv02 | ||
|
||
real(dp) function v03() | ||
v03 = 0.0d0 | ||
end function v03 | ||
|
||
real(dp) function dv03() | ||
dv03 = 0.0d0 | ||
end function dv03 | ||
|
||
real(dp) function ddv03() | ||
ddv03 = 0.0d0 | ||
end function ddv03 | ||
|
||
real(dp) function T0() | ||
T0 = cte_T0 | ||
end function T0 | ||
|
||
real(dp) function dT0() | ||
dT0 = 0.0d0 | ||
end function dT0 | ||
|
||
real(dp) function ddT0() | ||
ddT0 = 0.0d0 | ||
end function ddT0 | ||
|
||
end submodule |