Skip to content

Commit

Permalink
Makes the disk default parameters a module variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
luizfelippesr committed Oct 24, 2020
1 parent ed0eff7 commit fcc9544
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
58 changes: 30 additions & 28 deletions galmag/B_generators/B_generator_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@
from .B_generator import B_generator
import galmag.disk_profiles as prof

_default_disk_parameters = {
'disk_modes_normalization': np.array([1., 1., 1.]), # Cn_d
'disk_height': 0.5, # h_d
'disk_radius': 17.0, # R_d
'disk_turbulent_induction': 0.386392513, # Ralpha_d
'disk_dynamo_number': -20.4924192, # D_d
'disk_shear_function': prof.Clemens_Milky_Way_shear_rate, # S(r)
'disk_rotation_function': prof.Clemens_Milky_Way_rotation_curve, # V(r)
'disk_height_function': prof.exponential_scale_height, # h(r)
'disk_regularization_radius': None, # kpc
'disk_ref_r_cylindrical': 8.5, # kpc
'disk_field_decay': True,
'disk_newman_boundary_condition_envelope': False
}

class B_generator_disk(B_generator):
"""
Generator for the disk field
Expand Down Expand Up @@ -59,21 +74,8 @@ def __init__(self, grid=None, box=None, resolution=None,

@property
def _builtin_parameter_defaults(self):
builtin_defaults = {
'disk_modes_normalization': np.array([1., 1., 1.]), # Cn_d
'disk_height': 0.5, # h_d
'disk_radius': 17.0, # R_d
'disk_turbulent_induction': 0.386392513, # Ralpha_d
'disk_dynamo_number': -20.4924192, # D_d
'disk_shear_function': prof.Clemens_Milky_Way_shear_rate, # S(r)
'disk_rotation_function': prof.Clemens_Milky_Way_rotation_curve, # V(r)
'disk_height_function': prof.exponential_scale_height, # h(r)
'disk_regularization_radius': None, # kpc
'disk_ref_r_cylindrical': 8.5, # kpc
'disk_field_decay': True,
'disk_newman_boundary_condition_envelope': False
}
return builtin_defaults

return _default_disk_parameters


def find_B_field(self, B_phi_ref=-3.0, reversals=None,
Expand Down Expand Up @@ -132,14 +134,14 @@ def find_B_field(self, B_phi_ref=-3.0, reversals=None,

# The system of equations also accounts for the value at the Rsun
for j in range(self.modes_count):
tmp_parameters['disk_modes_normalization'] = \
tmp_parameters['disk_modes_normalization'] = \
np.zeros(self.modes_count)
tmp_parameters['disk_modes_normalization'][j] = 1
# Computes Bphi at the reference radius (this should be B_phi_ref)
Br, Bphi, Bz = self._convert_coordinates_to_B_values(
np.array([parsed_parameters['disk_ref_r_cylindrical'],]),
np.array([0.0,]), np.array([0.0,]), tmp_parameters)
A[i+1,j] = Bphi[0]
tmp_parameters['disk_modes_normalization'][j] = 1
# Computes Bphi at the reference radius (this should be B_phi_ref)
Br, Bphi, Bz = self._convert_coordinates_to_B_values(
np.array([parsed_parameters['disk_ref_r_cylindrical'],]),
np.array([0.0,]), np.array([0.0,]), tmp_parameters)
A[i+1,j] = Bphi[0]

results = np.zeros(len(reversals)+1)
results[i+1] = B_phi_ref
Expand Down Expand Up @@ -188,12 +190,12 @@ def get_B_field(self, **kwargs):
parsed_parameters)

result_field_obj = B_field_component(grid=self.grid,
r_cylindrical=Br,
phi=Bphi,
z=Bz,
dtype=self.dtype,
generator=self,
parameters=parsed_parameters)
r_cylindrical=Br,
phi=Bphi,
z=Bz,
dtype=self.dtype,
generator=self,
parameters=parsed_parameters)
return result_field_obj

def _convert_coordinates_to_B_values(self, r_cylindrical,
Expand Down
3 changes: 2 additions & 1 deletion galmag/halo_free_decay_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from sympy import besselj
from mpmath import mp, findroot
import os.path
pi=np.pi

pi = np.pi
cos = np.cos
tan = np.tan
sin = np.sin
Expand Down

0 comments on commit fcc9544

Please sign in to comment.