gyre icon indicating copy to clipboard operation
gyre copied to clipboard

unable to write structure coefficient V2 for polytropes

Open darthoctopus opened this issue 11 months ago • 2 comments

When writing out detail files for polytropes, I obtain a SIGFPE when trying to write out the $V_2$ coefficient in particular:

gyre [dev]
----------

OpenMP Threads   : 24
Input filename   : gyre.in

Model Init
----------

Reading from POLY file poly.simple.h5
   Read 367 points

Mode Search
-----------

Mode parameters
   l : 0
   m : 0

Building frequency grid (REAL axis)
   added scan interval :  0.7269E+00 ->  0.4362E+02 (100 points, LINEAR)

Building spatial grid
   Scaffold grid from model
   Refined 40 subinterval(s) in iteration 1
   Refined 23 subinterval(s) in iteration 2
   Refined 12 subinterval(s) in iteration 3
   Refined 4 subinterval(s) in iteration 4
   Refined 2 subinterval(s) in iteration 5
   Refined 2 subinterval(s) in iteration 6
   Refined 2 subinterval(s) in iteration 7
   Refined 2 subinterval(s) in iteration 8
   Refined 2 subinterval(s) in iteration 9
   Refined 2 subinterval(s) in iteration 10
   Refined 2 subinterval(s) in iteration 11
   Refined 2 subinterval(s) in iteration 12
   Refined 2 subinterval(s) in iteration 13
   Refined 2 subinterval(s) in iteration 14
   Refined 2 subinterval(s) in iteration 15
   Refined 2 subinterval(s) in iteration 16
   Refined 2 subinterval(s) in iteration 17
   Refined 0 subinterval(s) in iteration 18
   Final grid has 1 segment(s) and 472 point(s):
      Segment 1 : x range 0.0000 -> 1.0000 (1 -> 472)

Starting search (adiabatic)

Evaluating discriminant
  Time elapsed :     0.037 s

Root Solving
   l    m    n_pg    n_p    n_g       Re(omega)       Im(omega)        chi n_iter
   0    0       1      1      0  0.16449536E+01  0.00000000E+00 0.2737E-15      7

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.

Backtrace for this error:
#0  0x79a68205a76f in ???
#1  0x529fc0 in __gyre_poly_model_MOD_coeff_v_2_
#2  0x543724 in __gyre_detail_MOD_write
#3  0x409586 in process_mode_ad.1
#4  0x41aa1c in __gyre_bracket_search_MOD_bracket_search
#5  0x4071a0 in MAIN__
#6  0x405bb6 in main
[1]    2124786 floating point exception (core dumped)  $GYRE_DIR/bin/gyre gyre.in

This happens for me with at least both the current Git master, and as far back as version 6. Since the writing out of As appears to use V_2 as an intermediate step, including that in the detail files also causes a crash. This doesn't appear to depend on the polytrope index (I have tried 1.5 and 3).

darthoctopus avatar Mar 12 '24 05:03 darthoctopus

The reason for this is rather dull (I'm afraid): V_2 is infinite at the surface of polytropic models. One workaround is to set the outer boundary location to x = 0.9999 (say).

rhdtownsend avatar Mar 12 '24 07:03 rhdtownsend

I've tweaked the code so that V_2 will return inf at the surface of (complete) polytropic models. See 9484b30a0813e1e70c6397b0c15041a9e6f9a5bd

rhdtownsend avatar Apr 08 '24 16:04 rhdtownsend

This tweak is now live in the v7.2 release.

rhdtownsend avatar Jun 03 '24 16:06 rhdtownsend