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

matrix ionization calculation overwrites macro_pops values #498

Closed
jhmatthews opened this issue Apr 3, 2019 · 1 comment
Closed

matrix ionization calculation overwrites macro_pops values #498

jhmatthews opened this issue Apr 3, 2019 · 1 comment
Labels
bug Bugs in the code high macro-atom Issues to do with macro-atoms

Comments

@jhmatthews
Copy link
Collaborator

This is related to other issues, e.g. #493 - in trying to address the issues with macro-atoms, I think I've found a bug in the matrix ionization code when macro-atoms are used.

What I thought was supposed to happen is that, inside the loop over electron density, the ionization rate matrix for simple ions is calculated followed by a call to macro_pops to get the macro-atom level populations and ionization states. However, it seems to me that the densities that are copied over to the newden array and these overwrite the macro-atom ones:

    for (nn = 0; nn < nions; nn++)
    {
      newden[nn] = 0.0;         // initialise the array element

      /* if the ion is being treated by macro_pops then use the populations just computed */
      if ((ion[nn].macro_info == 1) && (geo.macro_simple == 0) && (geo.macro_ioniz_mode == 1))
      {
        newden[nn] = xplasma->density[nn] / elem_dens[ion[nn].z];
      }

      for (mm = 0; mm < nrows; mm++)    // inner loop over the elements of the population array
      {
        if (xion[mm] == nn)     // if this element contains the population of the ion is question
        {
          newden[nn] = populations[mm]; // get the population
        }
      }


      if (newden[nn] < DENSITY_MIN)     // this wil also capture the case where population doesnt have a value for this ion
        newden[nn] = DENSITY_MIN;
    }
    free (populations);

Sorry to raise another issue, but this one is potentially pretty important. Hopefully I've misunderstood something here.

@jhmatthews jhmatthews added bug Bugs in the code high macro-atom Issues to do with macro-atoms labels Apr 3, 2019
@jhmatthews
Copy link
Collaborator Author

Note that this doesn't affect in published work, but it does affect your TDE runs @saultyevil - it's not exactly "wrong" but it's not how we meant to do things and is inconsistent with the way we do stuff in the old non-matrix ion modes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs in the code high macro-atom Issues to do with macro-atoms
Projects
None yet
Development

No branches or pull requests

1 participant