-
-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update number of shells in SimulationState #2504
Changes from all commits
8b21e97
c841d4d
a0aa870
650d5e5
353effd
3b9cbea
65b17fb
3439832
f576f5e
8eacec5
e72df92
b1ced20
372e618
3969d9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -568,13 +568,12 @@ def parse_radiation_field_state( | |
|
||
if dilution_factor is None: | ||
dilution_factor = calculate_geometric_dilution_factor(geometry) | ||
elif len(dilution_factor) != geometry.no_of_shells: | ||
dilution_factor = dilution_factor[ | ||
geometry.v_inner_boundary_index : geometry.v_outer_boundary_index | ||
] | ||
assert len(dilution_factor) == geometry.no_of_shells | ||
|
||
return DiluteBlackBodyRadiationFieldState(t_radiative, dilution_factor) | ||
assert len(dilution_factor) == geometry.no_of_shells | ||
|
||
return DiluteBlackBodyRadiationFieldState( | ||
t_radiative, dilution_factor, geometry | ||
) | ||
|
||
|
||
def initialize_packet_source(config, geometry, packet_source): | ||
|
@@ -610,13 +609,13 @@ def initialize_packet_source(config, geometry, packet_source): | |
|
||
luminosity_requested = config.supernova.luminosity_requested | ||
if config.plasma.initial_t_inner > 0.0 * u.K: | ||
packet_source.radius = geometry.r_inner[0] | ||
packet_source.radius = geometry.r_inner_active[0] | ||
packet_source.temperature = config.plasma.initial_t_inner | ||
|
||
elif (config.plasma.initial_t_inner < 0.0 * u.K) and ( | ||
luminosity_requested is not None | ||
): | ||
packet_source.radius = geometry.r_inner[0] | ||
packet_source.radius = geometry.r_inner_active[0] | ||
packet_source.set_temperature_from_luminosity(luminosity_requested) | ||
else: | ||
raise ValueError( | ||
|
@@ -674,9 +673,6 @@ def parse_csvy_radiation_field_state( | |
t_radiative = ( | ||
np.ones(geometry.no_of_shells) * config.plasma.initial_t_rad | ||
) | ||
t_radiative = ( | ||
np.ones(geometry.no_of_shells) * config.plasma.initial_t_rad | ||
) | ||
else: | ||
t_radiative = calculate_t_radiative_from_t_inner( | ||
geometry, packet_source | ||
|
@@ -689,7 +685,9 @@ def parse_csvy_radiation_field_state( | |
else: | ||
dilution_factor = calculate_geometric_dilution_factor(geometry) | ||
|
||
return DiluteBlackBodyRadiationFieldState(t_radiative, dilution_factor) | ||
return DiluteBlackBodyRadiationFieldState( | ||
t_radiative, dilution_factor, geometry | ||
) | ||
|
||
|
||
def calculate_t_radiative_from_t_inner(geometry, packet_source): | ||
|
@@ -720,6 +718,12 @@ def calculate_geometric_dilution_factor(geometry): | |
return 0.5 * ( | ||
1 | ||
- np.sqrt( | ||
1 - (geometry.r_inner[0] ** 2 / geometry.r_middle**2).to(1).value | ||
1 | ||
- ( | ||
geometry.r_inner[geometry.v_inner_boundary_index] ** 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tried that but since r_inner_active[0] is overwrite by the v_inner_boundary value (which can be values in between the discrete shells), sometimes it can be a bigger value than the first element in r_middle, which cause the first w to be nan, and fails the assertion in the diluteBBradiationField. |
||
/ geometry.r_middle**2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. r_middle is the raw shells, but if we would like to keep the raw shape of the shells in radiationfield, then we should use r_middle I think. |
||
) | ||
.to(1) | ||
.value | ||
) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,18 +17,37 @@ class DiluteBlackBodyRadiationFieldState: | |
Radiative temperature in each shell | ||
dilution_factor : numpy.ndarray | ||
Dilution Factors in each shell | ||
geometry: tardis.model.Radial1DModel | ||
The geometry of the model that uses to constrains the active shells | ||
""" | ||
|
||
def __init__( | ||
self, | ||
t_radiative: u.Quantity, | ||
dilution_factor: np.ndarray, | ||
geometry=None, | ||
): | ||
# ensuring that the radiation_field has both | ||
# dilution_factor and t_radiative equal length | ||
assert len(t_radiative) == len(dilution_factor) | ||
assert np.all(t_radiative > 0 * u.K) | ||
assert np.all(dilution_factor > 0) | ||
if ( | ||
geometry is not None | ||
): # check the active shells only (this is used when setting up the radiation_field_state) | ||
assert np.all( | ||
t_radiative[ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this fixes the issue, but we probably ought to be setting the estimators shape as the active shells from the start. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is actually already being taken of, since the estimators only use the active shells, the simulation_state slice the active shells from the "raw" radiation_field_state. |
||
geometry.v_inner_boundary_index : geometry.v_outer_boundary_index | ||
] | ||
> 0 * u.K | ||
) | ||
assert np.all( | ||
dilution_factor[ | ||
geometry.v_inner_boundary_index : geometry.v_outer_boundary_index | ||
] | ||
> 0 | ||
) | ||
else: | ||
assert np.all(t_radiative > 0 * u.K) | ||
assert np.all(dilution_factor > 0) | ||
self.t_radiative = t_radiative | ||
self.dilution_factor = dilution_factor | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This modification is just to delete the duplicated codes