bendudson/hermes-3

Confusing X guard cell values for Pn, Nn, Tn

Closed this issue · 1 comments

I've been struggling with calculating perpendicular neutral particle and heat transport - I've been getting extreme values in the final radial fluid cells. I have now figured out what's wrong: the X guard cell values for Pn, Nn and Tn are zero.

If I manually set their value in the guard cells to the final radial cell value, my neutral transport calculation is correct, which suggests that this is what is happening inside the code, and the guard cells are set to zero at some other stage. I have not been able to find anything in the code that would do this though.

One thing I've realised is that I am not setting any boundary condition for Nn, Pn or Tn in the input file, and so they are set to dirichlet(0) by default. This is very confusing because neither of the above behaviours (guard cell = 0, or guard cell = final cell) corresponds to a dirichlet(0)!

neutral_mixed.cxx explicitly sets a dirichlet(0) condition on Dnn and I can confirm that the Dnn guard cell values do indeed correspond to this as opposed to Nn, Pn and Tn.

I have exposed the parameter BCs to the input file and made them all proper Neumann. This makes the guard cells look a lot more reasonable, see figure. After looking at the code (see here) what I think happens is that Hermes-3 applies a Dirichlet(0) by default, which causes the guard cell values to equal the negative of the final cell values. Then a floor is applied, and the guard cell becomes zero.

"Resolving" this by forcing a Neumann from the beginning does not change the answer, which makes sense as the code originally hardcodes a Neumann . See the below figure where I plot neutral parameters on the outer midplane (including the guard cells). Therefore, I don't think this is a bug anymore and have removed the label.

image