MPI-AMRVAC 3.2
The MPI - Adaptive Mesh Refinement - Versatile Advection Code (development version)
Loading...
Searching...
No Matches
mod_bfield.t
Go to the documentation of this file.
1!> Minimal magnetic-field-only state for static field construction.
2!>
3!> The B-only path deliberately registers only the magnetic components as
4!> conservative/primitive variables. It is intended for static potential
5!> (and other field-construction) cases; it does not provide a time-evolving
6!> induction equation. The legacy MHD-embedded magnetofriction path is
7!> intentionally unaffected by this module.
9 implicit none
10 public
11
12 !> Optional ionisation fractions used only by the unit normalisation.
13 double precision :: bfield_h_ion_fr=1.d0
14 double precision :: bfield_he_ion_fr=1.d0
15 double precision :: bfield_he_ion_fr2=1.d0
16
17contains
18
19 !> Activate the B-only physics/state path.
20 subroutine bfield_activate()
21 call bfield_phys_init()
22 end subroutine bfield_activate
23
24 subroutine bfield_read_params(files)
26
27 character(len=*), intent(in) :: files(:)
28 integer :: n
29
30 namelist /bfield_list/ bfield_h_ion_fr,bfield_he_ion_fr,&
32
33 do n=1,size(files)
34 open(unitpar,file=trim(files(n)),status='old')
35 read(unitpar,bfield_list,end=111)
36111 close(unitpar)
37 end do
38 end subroutine bfield_read_params
39
40 subroutine bfield_phys_init()
42 use mod_physics
43 use mod_functions_bfield, only: mag
44 use mod_eos_container, only: eos
45 use mod_comm_lib, only: mpistop
46
48
49 physics_type='bfield'
50 phys_energy=.false.
51 stagger_grid=.false.
52
53 allocate(mag(ndir))
54 mag(:)=var_set_bfield(ndir)
55
56 iwstart=mag(1)
57 allocate(start_indices(number_species),stop_indices(number_species))
58 start_indices(1)=mag(1)
59 stop_indices(1)=nwflux
60 nwgc=nwflux+nwaux
61 nws=0
62
63 nvector=1
64 allocate(iw_vector(nvector))
65 iw_vector(1)=mag(1)-1
66
67 if(.not.allocated(flux_type)) then
68 allocate(flux_type(ndir,nwflux))
70 else if(any(shape(flux_type)/=[ndir,nwflux])) then
71 call mpistop('bfield physics: flux_type has wrong shape')
72 end if
73
82
83 ! Keep the same normalisation as the MHD PotentialField case so that a
84 ! boundary file in Gauss maps to identical AMRVAC magnetic values.
86 end subroutine bfield_phys_init
87
90 use mod_physics, only: physics_type
91 use mod_geometry, only: coordinate
92
93 if(mype==0) then
94 write(*,*) '====B-only field construction settings==============='
95 write(*,*) 'physics_type=',trim(physics_type)
96 write(*,*) 'Dimensionality=',ndim,' vector components=',ndir
97 write(*,*) 'number of variables nw=',nw
98 write(*,*) 'start index iwstart=',iwstart
99 write(*,*) 'number of variables with BCs=',nwgc
100 write(*,*) 'number of variables with fluxes=',nwflux
101 write(*,*) 'coordinate set to type,slab:',coordinate,slab
102 write(*,*) 'unit_magneticfield=',unit_magneticfield
103 write(*,*) '======================================================='
104 end if
105 end subroutine bfield_check_params
106
107 subroutine bfield_to_conserved(ixI^L,ixO^L,w,x)
109 integer, intent(in) :: ixI^L,ixO^L
110 double precision, intent(inout) :: w(ixI^S,nw)
111 double precision, intent(in) :: x(ixI^S,1:^ND)
112 end subroutine bfield_to_conserved
113
114 subroutine bfield_to_primitive(ixI^L,ixO^L,w,x)
116 integer, intent(in) :: ixI^L,ixO^L
117 double precision, intent(inout) :: w(ixI^S,nw)
118 double precision, intent(in) :: x(ixI^S,1:^ND)
119 end subroutine bfield_to_primitive
120
121 subroutine bfield_get_cmax(w,x,ixI^L,ixO^L,idim,cmax)
123 integer, intent(in) :: ixI^L,ixO^L,idim
124 double precision, intent(in) :: w(ixI^S,nw),x(ixI^S,1:^ND)
125 double precision, intent(inout) :: cmax(ixI^S)
126
127 cmax(ixo^s)=zero
128 end subroutine bfield_get_cmax
129
130 subroutine bfield_get_cbounds(wLC,wRC,wLp,wRp,x,ixI^L,ixO^L,idim,&
131 Hspeed,cmax,cmin)
133 integer, intent(in) :: ixI^L,ixO^L,idim
134 double precision, intent(in) :: wLC(ixI^S,nw),wRC(ixI^S,nw)
135 double precision, intent(in) :: wLp(ixI^S,nw),wRp(ixI^S,nw)
136 double precision, intent(in) :: x(ixI^S,1:^ND)
137 double precision, intent(in) :: Hspeed(ixI^S,1:number_species)
138 double precision, intent(inout) :: cmax(ixI^S,1:number_species)
139 double precision, intent(inout), optional :: cmin(ixI^S,1:number_species)
140
141 cmax(ixo^s,1)=zero
142 if(present(cmin)) cmin(ixo^s,1)=zero
143 end subroutine bfield_get_cbounds
144
145 subroutine bfield_get_flux(wC,w,x,ixI^L,ixO^L,idim,f)
147 integer, intent(in) :: ixI^L,ixO^L,idim
148 double precision, intent(in) :: wC(ixI^S,nw),w(ixI^S,nw)
149 double precision, intent(in) :: x(ixI^S,1:^ND)
150 double precision, intent(out) :: f(ixI^S,nwflux)
151
152 f(ixo^s,1:nwflux)=zero
153 end subroutine bfield_get_flux
154
155 subroutine bfield_get_dt(w,ixI^L,ixO^L,dtnew,dx^D,x)
157 integer, intent(in) :: ixI^L,ixO^L
158 double precision, intent(in) :: dx^D,x(ixI^S,1:^ND)
159 double precision, intent(in) :: w(ixI^S,1:nw)
160 double precision, intent(inout) :: dtnew
161
162 dtnew=bigdouble
163 end subroutine bfield_get_dt
164
165 subroutine bfield_add_source_geom(qdt,dtfactor,ixI^L,ixO^L,wCT,wprim,w,x)
167 integer, intent(in) :: ixI^L,ixO^L
168 double precision, intent(in) :: qdt,dtfactor,x(ixI^S,1:^ND)
169 double precision, intent(inout) :: wCT(ixI^S,1:nw),wprim(ixI^S,1:nw),&
170 w(ixI^S,1:nw)
171 end subroutine bfield_add_source_geom
172
175 use mod_eos_container, only: eos
176
177 double precision :: mp,kB,miu0,c_lightspeed
178 double precision :: a,b,he
179 character(len=std_len) :: eos_type
180
181 if(si_unit) then
182 mp=mp_si
183 kb=kb_si
184 miu0=miu0_si
185 const_sigmasb=sigma_sb_si
186 c_lightspeed=c_si
187 else
188 mp=mp_cgs
189 kb=kb_cgs
190 miu0=4.d0*dpi
191 const_sigmasb=sigma_sb_cgs
192 c_lightspeed=const_c
193 end if
194
195 he=0.1d0
196 eos_type='FI'
197 if(allocated(eos)) then
198 he=eos%He_abundance
199 eos_type=eos%eos_type
200 end if
201
202 if(eos_type=='LTE') then
203 a=1.d0
204 b=1.d0
205 else
206 a=1.d0+4.d0*he
207 if(eos_type=='PI') then
209 (bfield_he_ion_fr2+1.d0)+1.d0)
210 else
211 b=2.d0+3.d0*he
212 end if
213 end if
214
215 if(unit_density/=1.d0 .or. unit_numberdensity/=1.d0) then
216 if(unit_density/=1.d0) then
218 else if(unit_numberdensity/=1.d0) then
220 end if
221 if(unit_temperature/=1.d0) then
225 if(unit_length/=1.d0) then
227 else if(unit_time/=1.d0) then
229 end if
230 else if(unit_magneticfield/=1.d0) then
234 if(unit_length/=1.d0) then
236 else if(unit_time/=1.d0) then
238 end if
239 else if(unit_pressure/=1.d0) then
243 if(unit_length/=1.d0) then
245 else if(unit_time/=1.d0) then
247 end if
248 else if(unit_velocity/=1.d0) then
252 if(unit_length/=1.d0) then
254 else if(unit_time/=1.d0) then
256 end if
257 else if(unit_time/=1.d0) then
262 end if
263 else if(unit_temperature/=1.d0) then
264 if(unit_magneticfield/=1.d0) then
269 if(unit_length/=1.d0) then
271 else if(unit_time/=1.d0) then
273 end if
274 else if(unit_pressure/=1.d0) then
279 if(unit_length/=1.d0) then
281 else if(unit_time/=1.d0) then
283 end if
284 end if
285 else if(unit_magneticfield/=1.d0) then
286 if(unit_velocity/=1.d0) then
291 if(unit_length/=1.d0) then
293 else if(unit_time/=1.d0) then
295 end if
296 else if(unit_time/=0.d0) then
302 end if
303 else if(unit_pressure/=1.d0) then
304 if(unit_velocity/=1.d0) then
309 if(unit_length/=1.d0) then
311 else if(unit_time/=1.d0) then
313 end if
314 else if(unit_time/=0.d0) then
320 end if
321 end if
322
323 c_norm=c_lightspeed/unit_velocity
325 if(.not.si_unit) unit_charge=unit_charge*const_c
327 end subroutine bfield_physical_units
328
329end module mod_bfield
Minimal magnetic-field-only state for static field construction.
Definition mod_bfield.t:8
subroutine bfield_get_cmax(w, x, ixil, ixol, idim, cmax)
Definition mod_bfield.t:122
subroutine bfield_get_dt(w, ixil, ixol, dtnew, dxd, x)
Definition mod_bfield.t:156
subroutine bfield_read_params(files)
Definition mod_bfield.t:25
subroutine bfield_get_cbounds(wlc, wrc, wlp, wrp, x, ixil, ixol, idim, hspeed, cmax, cmin)
Definition mod_bfield.t:132
double precision bfield_he_ion_fr
Definition mod_bfield.t:14
subroutine bfield_get_flux(wc, w, x, ixil, ixol, idim, f)
Definition mod_bfield.t:146
subroutine bfield_check_params
Definition mod_bfield.t:89
subroutine bfield_to_conserved(ixil, ixol, w, x)
Definition mod_bfield.t:108
subroutine bfield_phys_init()
Definition mod_bfield.t:41
double precision bfield_he_ion_fr2
Definition mod_bfield.t:15
subroutine bfield_to_primitive(ixil, ixol, w, x)
Definition mod_bfield.t:115
subroutine bfield_add_source_geom(qdt, dtfactor, ixil, ixol, wct, wprim, w, x)
Definition mod_bfield.t:166
subroutine bfield_activate()
Activate the B-only physics/state path.
Definition mod_bfield.t:21
double precision bfield_h_ion_fr
Optional ionisation fractions used only by the unit normalisation.
Definition mod_bfield.t:13
subroutine bfield_physical_units()
Definition mod_bfield.t:174
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
EoS state container – the single thermodynamic authority for AMRVAC.
type(eos_container), allocatable, public eos
The single EoS state object, allocated in eos_init and shared (read-mostly) across all EoS sub-module...
integer, dimension(:), allocatable, public mag
Indices of the magnetic field.
Module with geometry-related routines (e.g., divergence, curl)
Definition mod_geometry.t:2
integer coordinate
Definition mod_geometry.t:7
This module contains definitions of global parameters and variables and some generic functions/subrou...
double precision unit_charge
Physical scaling factor for charge.
double precision unit_time
Physical scaling factor for time.
double precision unit_density
Physical scaling factor for density.
integer, parameter unitpar
file handle for IO
double precision unit_mass
Physical scaling factor for mass.
double precision unit_numberdensity
Physical scaling factor for number density.
double precision unit_pressure
Physical scaling factor for pressure.
integer, parameter ndim
Number of spatial dimensions for grid variables.
double precision unit_length
Physical scaling factor for length.
logical stagger_grid
True for using stagger grid.
character(len=std_len), dimension(:), allocatable par_files
Which par files are used as input.
integer mype
The rank of the current MPI task.
integer ndir
Number of spatial dimensions (components) for vector variables.
logical slab
Cartesian geometry or not.
double precision unit_magneticfield
Physical scaling factor for magnetic field.
double precision unit_velocity
Physical scaling factor for velocity.
double precision c_norm
Normalised speed of light.
double precision unit_temperature
Physical scaling factor for temperature.
logical si_unit
Use SI units (.true.) or use cgs units (.false.)
This module defines the procedures of a physics module. It contains function pointers for the various...
Definition mod_physics.t:4
procedure(sub_convert), pointer phys_to_primitive
Definition mod_physics.t:52
procedure(sub_get_flux), pointer phys_get_flux
Definition mod_physics.t:65
procedure(sub_get_cbounds), pointer phys_get_cbounds
Definition mod_physics.t:64
procedure(sub_get_dt), pointer phys_get_dt
Definition mod_physics.t:71
procedure(sub_add_source_geom), pointer phys_add_source_geom
Definition mod_physics.t:72
procedure(sub_check_params), pointer phys_check_params
Definition mod_physics.t:49
integer, parameter flux_default
Indicates a normal flux.
Definition mod_physics.t:24
integer, dimension(:, :), allocatable flux_type
Array per direction per variable, which can be used to specify that certain fluxes have to be treated...
Definition mod_physics.t:21
procedure(sub_convert), pointer phys_to_conserved
Definition mod_physics.t:51
character(len=name_len) physics_type
String describing the physics type of the simulation.
Definition mod_physics.t:47
procedure(sub_get_cmax), pointer phys_get_cmax
Definition mod_physics.t:60
logical phys_energy
Solve energy equation or not.
Definition mod_physics.t:37