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

Wrong arguments passed to get_gamma_from_prim() in HydroState::calc_reconstruction() #7

Open
bezmi opened this issue Feb 10, 2023 · 0 comments

Comments

@bezmi
Copy link
Contributor

bezmi commented Feb 10, 2023

This one is a major bug and causes OOB errors when using the eilmer gas model. In MFP_hydro.cpp:1300-1318, the vectors alphas_lo and alphas_hi are used with tracer_idx=0. For our own ThermallyPerfectGas model, this works fine, since ThermallyPerfectGas::get_x_from_prim uses tracer_idx to correctly access the "primitives" vector to extract the alpha values. EilmerGasModel::get_x_from_prim calls EilmerGasModel::set_eilmer_gas_state_from_prim, which assumes that the primitives vector contains the state in the same order as HydroDef::PrimIdx, with alphas at their "correct" location.

The fix itself is not too difficult, but it raised a few questions for me. In order for the next few things to make sense, it's best to follow the get_gamma_from_prim function into EilmerGasModel and all the way through to MFP::wrap_gas.cpp which contains the ffi stuff to communicate with eilmer.

  1. Currently, gamma_hi and gamma_lo are used to calculate P_lo and P_hi in the reconstruction. I don't think this is consistent with the way it's expected to be done in eilmer, especially since the set_eilmer_gas_state_from_prim function uses gas_model_gas_state_update_thermo_from_rhop. If we only pass in updated alphas and run an update, won't it be using a random old value for rho and p? Perhaps for the reconstruction step, this function should actually be ...update_thermo_from_rhou and we should be passing through rho_lo, eps_lo (internal energy) and alphas_lo?
  2. The temperature calculation in the reconstruction makes a calorically perfect gas assumption. For molecular species, the temperature that we calculate and store is different to the temperature that is output by eilmer since it uses a Newton solver to calculate a temperature consistent with the specific heats and two state variables. Maybe we should rely on the gas model classes (eilmer or our own) to provide the EOS? Eg, calc_reconstruction calculates rho_lo, eps_lo and alphas_lo using the cell slopes and then calls a method in the gas class to get the corresponding T, P, Cp and gamma. This way the reconstructed primitives will be consistent with whatever gas model is being used for that species.
  3. As noted in previous discussions, we have to be careful about how we handle cases like the following:
    3a. Dissociation of N2 into N using eilmer
    3b. Electron impact ionisation of the same N into N+ using our multi-fluid rates

I have tried an implementation of the stuff discussed in (1) and (2), but eilmer is not able to converge on temperature, so clearly I'm missing something still. I think the gas_kinetics source term does some of this too.

The microphysics routines for the EOS in Castro are probably worth looking at for an example of how others have implemented multiple gas models in their simulations. I'm not sure if they handle interactions between different gas models though. They also augment their equations with the internal energy equation, stating improved numerics at high mach numbers and with source terms that might change the internal energy.

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

1 participant