From 109df817b9cf7178953769bb65a9b2c24918a235 Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Sat, 23 Mar 2024 11:02:43 +0530 Subject: [PATCH 01/12] Fix in parse_structure_config documentation string --- tardis/model/parse_input.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index 9dd4aa8baf1..dae5a627e85 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -33,42 +33,6 @@ def parse_structure_config(config, time_explosion, enable_homology=True): """ Parse the structure configuration data. - Parameters - ---------- - config : object - The configuration data. - time_explosion : float - The time of the explosion. - enable_homology : bool, optional - Whether to enable homology (default is True). - - Returns - ------- - electron_densities : object - The parsed electron densities. - temperature : object - The parsed temperature. - geometry : object - The parsed geometry. - density : object - The parsed density. - - Raises - ------ - NotImplementedError - If the structure configuration type is not supported. - - Notes - ----- - This function parses the structure configuration data and returns the parsed electron - densities, temperature, geometry, and density. The structure configuration can be of - type 'specific' or 'file'. If it is of type 'specific', the velocity and density are - parsed from the configuration. If it is of type 'file', the velocity and density are - read from a file. The parsed data is used to create a homologous radial 1D geometry object. - """ - """ - Parse the structure configuration data. - Parameters ---------- config : object From 6ea9fbaf712d43fb4c58738e7546af9b051f1d2c Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Sat, 23 Mar 2024 11:56:03 +0530 Subject: [PATCH 02/12] Documentation Typo --- tardis/model/geometry/radial1d.py | 4 ++-- tardis/model/parse_input.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tardis/model/geometry/radial1d.py b/tardis/model/geometry/radial1d.py index 53f21fbeed3..a6bf3382cbc 100644 --- a/tardis/model/geometry/radial1d.py +++ b/tardis/model/geometry/radial1d.py @@ -11,10 +11,10 @@ class HomologousRadial1DGeometry: Parameters ---------- - r_inner : astropy.units.quantity.Quantity - r_outer : astropy.units.quantity.Quantity v_inner : astropy.units.quantity.Quantity v_outer : astropy.units.quantity.Quantity + v_inner_boundary : astropy.units.quantity.Quantity + v_outer_boundary : astropy.units.quantity.Quantity Attributes ---------- diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index dae5a627e85..d2c97235e77 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -109,8 +109,8 @@ def parse_structure_config(config, time_explosion, enable_homology=True): ) density = density[1:] geometry = HomologousRadial1DGeometry( - velocity[:-1], # r_inner - velocity[1:], # r_outer + velocity[:-1], # v_inner + velocity[1:], # v_outer v_inner_boundary=structure_config.get("v_inner_boundary", None), v_outer_boundary=structure_config.get("v_outer_boundary", None), time_explosion=time_explosion, From f9fa64986c035c3bc888df04d11369f9a960494f Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Sat, 23 Mar 2024 12:44:45 +0530 Subject: [PATCH 03/12] Another type --- tardis/model/parse_input.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index d2c97235e77..7cb91d7dde6 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -181,8 +181,8 @@ def parse_csvy_geometry( velocity = velocity.to("cm/s") geometry = HomologousRadial1DGeometry( - velocity[:-1], # r_inner - velocity[1:], # r_outer + velocity[:-1], # v_inner + velocity[1:], # v_outer v_inner_boundary=v_boundary_inner, v_outer_boundary=v_boundary_outer, time_explosion=time_explosion, From 66c4283ce82a31b08ca9ac3e002cf69b7c576e25 Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Sat, 23 Mar 2024 14:40:15 +0530 Subject: [PATCH 04/12] Fix --- tardis/model/parse_input.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index 7cb91d7dde6..58a72a1ee19 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -687,10 +687,8 @@ def calculate_t_radiative_from_t_inner(geometry, packet_source): Quantity The calculated radiative temperature. """ - lambda_wien_inner = const.b_wien / packet_source.temperature - t_radiative = const.b_wien / ( - lambda_wien_inner - * (1 + (geometry.v_middle - geometry.v_inner_boundary) / const.c) + t_radiative = packet_source.temperature / ( + (1 - (geometry.v_middle - geometry.v_inner_boundary) / const.c) ) return t_radiative From e42b6a03f4c2b237c81f8b0d4fcfc215b6010e7f Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Sat, 23 Mar 2024 11:02:43 +0530 Subject: [PATCH 05/12] Fix in parse_structure_config documentation string --- tardis/model/parse_input.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index 4b47a77d858..276e8785d47 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -33,42 +33,6 @@ def parse_structure_config(config, time_explosion, enable_homology=True): """ Parse the structure configuration data. - Parameters - ---------- - config : object - The configuration data. - time_explosion : float - The time of the explosion. - enable_homology : bool, optional - Whether to enable homology (default is True). - - Returns - ------- - electron_densities : object - The parsed electron densities. - temperature : object - The parsed temperature. - geometry : object - The parsed geometry. - density : object - The parsed density. - - Raises - ------ - NotImplementedError - If the structure configuration type is not supported. - - Notes - ----- - This function parses the structure configuration data and returns the parsed electron - densities, temperature, geometry, and density. The structure configuration can be of - type 'specific' or 'file'. If it is of type 'specific', the velocity and density are - parsed from the configuration. If it is of type 'file', the velocity and density are - read from a file. The parsed data is used to create a homologous radial 1D geometry object. - """ - """ - Parse the structure configuration data. - Parameters ---------- config : object From 8efec586ae71b7dd6d41111fabdc6443d60e99c3 Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Sat, 23 Mar 2024 11:56:03 +0530 Subject: [PATCH 06/12] Documentation Typo --- tardis/model/geometry/radial1d.py | 4 ++-- tardis/model/parse_input.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tardis/model/geometry/radial1d.py b/tardis/model/geometry/radial1d.py index 53f21fbeed3..a6bf3382cbc 100644 --- a/tardis/model/geometry/radial1d.py +++ b/tardis/model/geometry/radial1d.py @@ -11,10 +11,10 @@ class HomologousRadial1DGeometry: Parameters ---------- - r_inner : astropy.units.quantity.Quantity - r_outer : astropy.units.quantity.Quantity v_inner : astropy.units.quantity.Quantity v_outer : astropy.units.quantity.Quantity + v_inner_boundary : astropy.units.quantity.Quantity + v_outer_boundary : astropy.units.quantity.Quantity Attributes ---------- diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index 276e8785d47..cf163301049 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -109,8 +109,8 @@ def parse_structure_config(config, time_explosion, enable_homology=True): ) density = density[1:] geometry = HomologousRadial1DGeometry( - velocity[:-1], # r_inner - velocity[1:], # r_outer + velocity[:-1], # v_inner + velocity[1:], # v_outer v_inner_boundary=structure_config.get("v_inner_boundary", None), v_outer_boundary=structure_config.get("v_outer_boundary", None), time_explosion=time_explosion, From b4ceb538364ba4e2209b0e9e037c9493b8d5b216 Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Sat, 23 Mar 2024 12:44:45 +0530 Subject: [PATCH 07/12] Another type --- tardis/model/parse_input.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index cf163301049..d7e73712a97 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -181,8 +181,8 @@ def parse_csvy_geometry( velocity = velocity.to("cm/s") geometry = HomologousRadial1DGeometry( - velocity[:-1], # r_inner - velocity[1:], # r_outer + velocity[:-1], # v_inner + velocity[1:], # v_outer v_inner_boundary=v_boundary_inner, v_outer_boundary=v_boundary_outer, time_explosion=time_explosion, From 035c78924e5860139467a323b9692a4bab532179 Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Sat, 23 Mar 2024 14:40:15 +0530 Subject: [PATCH 08/12] Fix --- tardis/model/parse_input.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index d7e73712a97..8f01059e35d 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -699,10 +699,8 @@ def calculate_t_radiative_from_t_inner(geometry, packet_source): Quantity The calculated radiative temperature. """ - lambda_wien_inner = const.b_wien / packet_source.temperature - t_radiative = const.b_wien / ( - lambda_wien_inner - * (1 + (geometry.v_middle - geometry.v_inner_boundary) / const.c) + t_radiative = packet_source.temperature / ( + (1 - (geometry.v_middle - geometry.v_inner_boundary) / const.c) ) return t_radiative From b516b6aa0c6b6f1c39dad3b730a0d35ae590c141 Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Fri, 3 May 2024 02:43:13 +0530 Subject: [PATCH 09/12] Redo the change to original and updated the documentation --- docs/physics/setup/model.ipynb | 6 +++--- tardis/model/parse_input.py | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/physics/setup/model.ipynb b/docs/physics/setup/model.ipynb index 9c989b30c2c..a74cf57b31c 100644 --- a/docs/physics/setup/model.ipynb +++ b/docs/physics/setup/model.ipynb @@ -485,13 +485,13 @@ "\n", "$$T=\\frac{b}{\\lambda_\\mathrm{peak}}.$$\n", "\n", - "Since we know $T_\\mathrm{inner}$ (from the previous calculation), at the photosphere, we have $\\lambda_\\mathrm{peak,inner}=\\frac{b}{T_\\mathrm{inner}}$. Now, when the ejecta is moving at a velocity $v$, $\\lambda_\\mathrm{peak}$ is doppler shifted (in more technical language, we find the peak wavelength in the co-moving frame, see [reference frames](../montecarlo/propagation.rst#reference-frames)). The doppler factor is (approximately) $1-\\frac{\\Delta v}{c}$ where $\\Delta v$ is the difference between $v$ and the velocity at the photosphere (i.e. $\\Delta v = v-v_\\mathrm{boundary\\_inner}$). So,\n", + "Since we know $T_\\mathrm{inner}$ (from the previous calculation), at the photosphere, we have $\\lambda_\\mathrm{peak,inner}=\\frac{b}{T_\\mathrm{inner}}$. Now, when the ejecta is moving at a velocity $v$, $\\lambda_\\mathrm{peak}$ is doppler shifted (in more technical language, we find the peak wavelength in the co-moving frame, see [reference frames](../montecarlo/propagation.rst#reference-frames)). The doppler factor is (approximately) $1+\\frac{\\Delta v}{c}$ where $\\Delta v$ is the difference between $v$ and the velocity at the photosphere (i.e. $\\Delta v = v-v_\\mathrm{boundary\\_inner}$). So,\n", "\n", - "$$\\lambda_\\mathrm{peak}(v)=\\left(1-\\frac{v-v_\\mathrm{boundary\\_inner}}{c}\\right)\\lambda_\\mathrm{peak,inner}=\\left(1-\\frac{v-v_\\mathrm{boundary\\_inner}}{c}\\right)\\frac{b}{T_\\mathrm{inner}}.$$\n", + "$$\\lambda_\\mathrm{peak}(v)=\\left(1+\\frac{v-v_\\mathrm{boundary\\_inner}}{c}\\right)\\lambda_\\mathrm{peak,inner}=\\left(1+\\frac{v-v_\\mathrm{boundary\\_inner}}{c}\\right)\\frac{b}{T_\\mathrm{inner}}.$$\n", "\n", "Thus, the temperature at a velocity $v$ is\n", "\n", - "$$T_\\mathrm{rad}(v)=\\frac{b}{\\lambda_\\mathrm{peak}(v)}=\\frac{T_\\mathrm{inner}}{1-\\frac{v-v_\\mathrm{boundary\\_inner}}{c}}.$$\n", + "$$T_\\mathrm{rad}(v)=\\frac{b}{\\lambda_\\mathrm{peak}(v)}=\\frac{T_\\mathrm{inner}}{1+\\frac{v-v_\\mathrm{boundary\\_inner}}{c}}.$$\n", "\n", "As with density, the radiative temperature is modeled as constant throughout the shell, so we determine the temperature of the shell based on the ejecta's velocity at the center of the shell.\n", "\n", diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index 8f01059e35d..30370891f07 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -699,8 +699,10 @@ def calculate_t_radiative_from_t_inner(geometry, packet_source): Quantity The calculated radiative temperature. """ - t_radiative = packet_source.temperature / ( - (1 - (geometry.v_middle - geometry.v_inner_boundary) / const.c) + lambda_wien_inner = const.b_wein / packet_source.temperature + t_radiative = const.b_wien / ( + lambda_wien_inner + * (1 + (geometry.v_middle - geometry.v_inner_boundary) / const.c) ) return t_radiative @@ -712,7 +714,7 @@ def calculate_geometric_dilution_factor(geometry): 1 - ( geometry.r_inner[geometry.v_inner_boundary_index] ** 2 - / geometry.r_middle**2 + / geometry.r_middle ** 2 ) .to(1) .value From 62a43468c735ccab5bf07da44a634de11458fa46 Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Fri, 3 May 2024 02:54:59 +0530 Subject: [PATCH 10/12] Undo the original --- tardis/model/parse_input.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index 968b3c9ae22..30370891f07 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -699,15 +699,10 @@ def calculate_t_radiative_from_t_inner(geometry, packet_source): Quantity The calculated radiative temperature. """ -<<<<<<< HEAD lambda_wien_inner = const.b_wein / packet_source.temperature t_radiative = const.b_wien / ( lambda_wien_inner * (1 + (geometry.v_middle - geometry.v_inner_boundary) / const.c) -======= - t_radiative = packet_source.temperature / ( - (1 - (geometry.v_middle - geometry.v_inner_boundary) / const.c) ->>>>>>> 66c4283ce82a31b08ca9ac3e002cf69b7c576e25 ) return t_radiative From ff52279a3c8f2c11c0912857e07026c9bd2ee968 Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Fri, 3 May 2024 02:56:28 +0530 Subject: [PATCH 11/12] Spelling Typo --- tardis/model/parse_input.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index 30370891f07..5302ad447d6 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -699,7 +699,7 @@ def calculate_t_radiative_from_t_inner(geometry, packet_source): Quantity The calculated radiative temperature. """ - lambda_wien_inner = const.b_wein / packet_source.temperature + lambda_wien_inner = const.b_wien / packet_source.temperature t_radiative = const.b_wien / ( lambda_wien_inner * (1 + (geometry.v_middle - geometry.v_inner_boundary) / const.c) From a0f2dad49b280c0b01ec3192b119a78e03d3f91b Mon Sep 17 00:00:00 2001 From: Sumit112192 Date: Fri, 3 May 2024 03:09:25 +0530 Subject: [PATCH 12/12] Undo the change by black --- tardis/model/parse_input.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tardis/model/parse_input.py b/tardis/model/parse_input.py index 5302ad447d6..d7e73712a97 100644 --- a/tardis/model/parse_input.py +++ b/tardis/model/parse_input.py @@ -714,7 +714,7 @@ def calculate_geometric_dilution_factor(geometry): 1 - ( geometry.r_inner[geometry.v_inner_boundary_index] ** 2 - / geometry.r_middle ** 2 + / geometry.r_middle**2 ) .to(1) .value