usnistgov / fipy

FiPy is a Finite Volume PDE solver written in Python
http://pages.nist.gov/fipy/en/latest
Other
504 stars 148 forks source link

Shock tube eqs #1058

Open Fratorhe opened 1 month ago

Fratorhe commented 1 month ago

Hello,

I am trying to implement the shock tube equations as described in: https://en.wikipedia.org/wiki/MUSCL_scheme Currently, I have implemented it as described in the attached file. However, I get this error: AttributeError: 'binOp' object has no attribute 'divergence'. I used the term (u * p).divergence as described in the FAQ

shocktube (copy).txt

Instead, if I rewrite the term (u * p).divergence as: + p.grad[0] * u + u.grad[0] * p The code performs decently well, leading to the comparison shown in the attachments compared to literature values (dashed -- lines). The two solid lines correspond to:

velocity_comparison.pdf pressure_comparison.pdf density_comparison.pdf

Could you give me some advice on the best way to set it up?

Best, Francisco

PS. I saw this old mailing list post: https://fipy.nist.narkive.com/ZLce9x2l/compressible-euler-equations but the files are not attached...

wd15 commented 1 month ago

It appears that .divergence doesn't work for CellVariables. It does work for FaceVariables so it's best to evaluate (u * p) as a FaceVariable. Use (u.faceValue * p.faceValue).divergence to make it work. It's best to use that form as u and p might be constrained on the boundaries and this format should pick that up (instead of (u * p).faceValue.divergence).

Note that the text at the end of this section in the FAQ appears to suggest that .divergence does exist for CellVariables, which is not the case.

Fratorhe commented 1 month ago

This worked well, thanks a lot!