Skip to content
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

Custom abundance model not reading the abundances of the first shell #2655

Closed
1 of 2 tasks
gayatri-p opened this issue Jun 13, 2024 · 2 comments
Closed
1 of 2 tasks

Comments

@gayatri-p
Copy link

Describe the bug
When running TARDIS simulation with a custom density and abundance profile, the following Value error pops up.

raise ValueError(
ValueError: Unable to coerce to Series, length must be 6: given 7

To Reproduce

When the line producing the error is traced, one can see that the error is produced due to TARDIS not reading the first shell in the csv part of the csvy file. For example:

abund.csvy

---
name: cvy_model_abundance_dataframes
model_density_time_0: 1 day
model_isotope_time_0: 0 day
description: csvy file to test abundances and decay (test values declared in the CSV section) 
tardis_model_config_version: v1.0
datatype:
  fields:
    -  name: velocity
       unit: km/s
       desc: velocities of shell outer bounderies.
    -  name: density
       unit: g/cm^3
       desc: density of shell.
    -  name: H
       desc: fractional H abundance
    -  name: He
       desc: fractional He abundance
    -  name: Ni56 
       desc: fractional Ni56 abundance

v_inner_boundary: 9000 km/s
v_outer_boundary: 16000 km/s
---
velocity,density,H,He,Ni56
9000,  5e-10,   0.5,  0.5,  0
10500, 2.0e-10, 0.0,  0.98, 0.02
12000, 9e-11,   0.33, 0.64, 0.03 
13000, 9e-12,   0.3,  0.6,  0.1
14000, 6e-12,   0.5,  0.4,  0.1
15000, 4e-12,   0.4,  0.55, 0.05
16000, 3e-12,   0.2,  0.79, 0.01

config.yml

tardis_config_version: v1.0

supernova:
  luminosity_requested: 8.64 log_lsun
  time_explosion: 6.8 day

atom_data: kurucz_cd23_chianti_H_He.h5
csvy_model: abund.csvy
plasma:
  disable_electron_scattering: no
  ionization: lte
  excitation: dilute-lte
  radiative_rates_type: dilute-blackbody
  line_interaction_type: scatter

montecarlo:
  seed: 23111963
  no_of_packets: 4.0e+4
  iterations: 30
  nthreads: 4 

  last_no_of_packets: 1.e+5
  no_of_virtual_packets: 10

  convergence_strategy:
    type: damped
    damping_constant: 0.005
    threshold: 0.05
    fraction: 0.8
    hold_iterations: 3
    t_inner:
      damping_constant: 1.0

spectrum:
  start: 500 angstrom
  stop: 20000 angstrom
  num: 10000

sim.py

from tardis import run_tardis
sim2 = run_tardis("config.yml", log_level='INFO', show_convergence_plots=False, virtual_packet_logging=True)

Screenshots
image

System

  • OS:
    • GNU/Linux
    • macOS

Temporary workaround

Since we figured out that the error was caused by all the density parameters being read while the first shell's mass fractions are ignored, by changing line 165 in file /site-packages/tardis/model/base.py to

@property
def elemental_number_density(self):
    self.composition.density = self.composition.density[1:] # adding this line temporarily fixes the error since it ignores the density of the first shell read.
    elemental_number_density = (
        (
            self.composition.elemental_mass_fraction
            * self.composition.density
        )
        .divide(self.composition.element_masses, axis=0)
        .dropna()
    )

Since this is not a permanent solution, please suggest how to solve this problem.

@andrewfullard
Copy link
Contributor

We will be resolving the problem in #2652

@Knights-Templars
Copy link
Member

Issue was solved in PR #2652. If it still fails, open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants