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

High precision in loop length input can lead to segmentation fault in initial conditions #82

Open
wtbarnes opened this issue Dec 11, 2020 · 11 comments
Labels

Comments

@wtbarnes
Copy link
Member

I'm running into a case where running the initial conditions is throwing a segmentation fault and I have no idea why. I have two cases of very long loops with similar lengths, a loop with length 117 Mm (loop 36) and a loop with length 124 Mm (loop 47). The initial conditions code for loop 36 runs and produces a hydrostatic solution with no issue. Loop 47 throws a segmentation fault. The only difference between the two is the length and I cannot understand why the second would result in a segmentation fault and not the first. I have attached the two configured simulations here.

I have turned off both the gravity and expansion profiles for the initial conditions step as well so I cannot imagine that could be causing the problem either.

loop000036.tar.gz
loop000047.tar.gz

@wtbarnes
Copy link
Member Author

Just for completeness, here are the initial conditions for the simulation that does not throw a seg fault (loop 36). Everything seems as expected

image

@sjbradshaw
Copy link
Contributor

sjbradshaw commented Dec 11, 2020 via email

@wtbarnes
Copy link
Member Author

This appears to be a Linux-versus-Mac (and possibly Windows as well) issue. @jwreep and I have both confirmed that both of these configurations work on Mac, but not Linux. Additionally, it seems that configuring a nearly identical setup with the GUI does not lead to this seg fault, but doing the setup in Python (with pydrad) does. Why one succeeds and the other does not is beyond me.

@wtbarnes
Copy link
Member Author

Ah okay. Thanks! That is very odd indeed. The high precision in the loop length is because these lengths are derived from a field extrapolation and thus are automatically generated. It is easy enough to just add some code to the configuration to truncate the precision.

@wtbarnes wtbarnes changed the title Segmentation fault in initial conditions High precision in loop length input can lead to segmentation fault in initial conditions Dec 11, 2020
@wtbarnes
Copy link
Member Author

I've changed the name of the issue here and I'll leave it open just in case someone else (or my future self!) stumbles across this again.

@wtbarnes wtbarnes added the bug label Dec 11, 2020
@jwreep
Copy link
Member

jwreep commented Dec 11, 2020

Based on Steve's response, have you tried simply setting in pydrad MIN_CELLS to 1 + the current number? It sounds like this might be a one-off issue due to truncating the precision.

@sjbradshaw
Copy link
Contributor

sjbradshaw commented Dec 11, 2020 via email

@wtbarnes
Copy link
Member Author

I'm now seeing this issue pop up again, this time for smaller loop lengths. In the pydrad configuration code, I've switched to writing the loop length out in scientific notation with 8 significant digits (I realize this is still far more than needed). I've also changed the calculation of the minimum number of cells to be ceil(L / min_grid_size) + 1 per Jeff's comment.

There are no issues with the longer loop lengths I mentioned previously. However, for a loop with length ~45 Mm, I'm now seeing the following runtime error,

Calculating initial hydrostatic conditions...

Peak heating range = 3.5481e-04 -> 3.6308e-04 erg cm^-3 s^-1

Optimum peak heating rate = 3.6039e-04 erg cm^-3 s^-1

Writing initial conditions file...

corrupted size vs. prev_size
[1]    21406 abort (core dumped)  ./Initial_Conditions.exe

Reducing the number of significant figures for the loop length in the configuration (even down to 2, e.g. 4.45e+9) just leads to the same segmentation fault as before. I've attached the configuration here.

loop000059.tar.gz

@sjbradshaw
Copy link
Contributor

sjbradshaw commented Dec 12, 2020 via email

@wtbarnes
Copy link
Member Author

I'm able to run the initial conditions setting MAX_CELLS to 5000 as well.

In pydrad, I'm calculating the maximum number of cells as floor(2^{RL} * L / ds_max) where RL is the refinement level,

https://github.com/rice-solar-physics/pydrad/blob/d4fdbf713e1dc1a6629308ba4adb5e0fbb7c3908/pydrad/configure/configure.py#L421-L439

Is this not correct? I've already added an option in the pydrad to just override this calculation by specifying maximum_cells in the configuration.

@sjbradshaw
Copy link
Contributor

sjbradshaw commented Dec 13, 2020 via email

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

No branches or pull requests

3 participants