danieljprice / phantom

Phantom Smoothed Particle Hydrodynamics and Magnetohydrodynamics code
https://phantomsph.github.io
Other
103 stars 223 forks source link

Something wrong with grtde simulation and star setup #465

Closed Shigaharuki3012 closed 3 months ago

Shigaharuki3012 commented 1 year ago

When I run grtde simulation setup,errors appeared like:

reading setup options from grtde.setup
 opening database from grtde.setup with 11 entries
 ERROR: tol_ekin not found
 ERROR: maxits not found
  2 error(s) during read of setup file: re-writing...
 writing setup options file grtde.setup
  Edit grtde.setup and rerun phantomsetup

though the file would be completed shortly after running this. Also,I recommend that setups for star in grtde.setup should be added during grtde simulation,but now we can not setup more parameters except several options.For example ,we can not set the code unit because the default Msun has been determined.(see below)

# input file for tidal disruption setup

# options for star 
            iprofile =           2    ! 0=Sink,1=Unif,2=Poly,3=Dens,4=KEPL,5=MESA,6=Pie
               Mstar =       1.000    ! mass of star  [Msun]
               Rstar =       1.000    ! radius of star [Rsun]
                  np =       10000    ! number of particles
               relax =           T    ! relax star into hydrostatic equilibrium
            tol_ekin =   1.000E-07    ! tolerance on ekin/epot to stop relaxation
              maxits =        1000    ! maximum number of relaxation iterations

# options for black hole and orbit
               mhole =   1.000E+06    ! mass of black hole (solar mass)
                beta =       5.000    ! penetration factor
                 ecc =       0.950    ! eccentricity (1 for parabolic)
             norbits =       5.000    ! number of orbits
       dumpsperorbit =         100    ! number of dumps per orbit
               theta =         60.    ! inclination of orbit (degrees)
Shigaharuki3012 commented 1 year ago

also,the value of Mbh and MStar are not shown correctly in tde.in,where Mbh=1,Mstar=1e-6,while the original settings are Mbh=1e6 and Mstar=1 (For solarr unit).Or is it normal in this case for the programm is to scale the Mbh and Mstar?(That is ,we only have to make Mbh/Mstar=1e6 but don't care about the exact value?) Also see below:

 >>>>>>  s  t  r  e   t    c     h       m     a    p   p  i  n  g  <<<<<<
 stretching to match tabulated density profile in r direction
 density at r =   0.000000000000000E+000  is   1.365239004866886E-005
 total mass      =   9.993580636893520E-007
 >>>>>> done

 rstar =   0.471307068490007       mstar =   9.993580636925984E-007  tdyn =    359.501120595696     
 Centre of mass is at (x,y,z) = (-1.007E-18,  8.059E-20, -7.595E-20)
 Particle setup OK
[sc50687@ln23%bscc-a grtde_try]$ tail slurm-7457060.out 
 rstar =   0.471307068490007       mstar =   9.993580636925984E-007  tdyn =    359.501120595696 

And relaxation of star seems problematic once a lots of particles are setted like 200k particles.But things get normal for 1e4 particles or less.

See below:

Relaxing star: Iter 510/1000, dens error:  0.54%, R*:  0.441     Ekin/Epot:  1.936E-07
  pmom =                     NaN                     NaN                     NaN
  rho* =  9.306439527429406E-006
  en   =                     NaN

 FATAL ERROR! cons2prim: could not solve rootfinding on particle 95311
danieljprice commented 11 months ago

I'm not sure what the issue is here, you are in the GR code so you must have G=M=c=1 and the only unit freedom is to set the mass unit, typically we set M=1 for the black hole. Please clarify exactly what the problem is?

Is the problem you get NaNs on relaxing the star? If so exactly what parameters are needed to reproduce this?

tajjankovic commented 6 months ago

I can reproduce the issue described above during the relaxation process for SETUP=grtde:

FATAL ERROR! cons2prim: could not solve rootfinding on particle...

star.setup parameters I used:

options for star

        iprofile =           2    ! 0=Sink,1=Unif,2=Poly,3=Dens,4=KEPL,5=MESA,6=Pie
           Mstar =       1.000    ! mass of star  [Msun]
           Rstar =       1.000    ! radius of star [Rsun]
              np =       100000    ! number of particles
           relax =           T    ! relax star into hydrostatic equilibrium
        tol_ekin =   1.000E-07    ! tolerance on ekin/epot to stop relaxation
          maxits =        1000    ! maximum number of relaxation iterations

options for black hole and orbit

           mhole =   1.000E+06    ! mass of black hole (solar mass)
            beta =       5.000    ! penetration factor
             ecc =       0.800    ! eccentricity (1 for parabolic)
         norbits =       5.000    ! number of orbits
   dumpsperorbit =         100    ! number of dumps per orbit
           theta =       0.000    ! inclination of orbit (degrees)

Steps to reproduce the error: $PHANTOM_DIR/scripts/writemake.sh grtde>Makefile;make setup;make;./phantomsetup star Error:

FATAL ERROR! cons2prim: could not solve rootfinding on particle 50005 pmom = 0.0000000000000000 0.0000000000000000 0.0000000000000000
rho* = 3.2251316183968794E-006

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

tajjankovic commented 5 months ago

The reason for this problem might related to the 116th line in .../main/deriv.f90 file

   !call prim2consall(npart,xyzh,metrics,vxyzu,dens,pxyzu,use_dens=.false.)

If this line is uncommented, the relaxation process runs without issues. @danieljprice @Fitz-Hu @dliptai could you comment on this? Is the correct approach to uncomment this line when relaxing stars for GR simulations, and then comment the line when doing GR TDE simulations?

danieljprice commented 4 months ago

definitely most people have set up an isolated star followed by the moddump_tde procedure to place it in orbit. The one-stop setup_grtde procedure is new... I'm not sure what is going wrong here. In the meantime I'd suggest to fall back to the "regular" SETUP=grstar followed by moddump procedure if it's not working for you..

tajjankovic commented 4 months ago

Hey Daniel,

I also found these notes from the ANITA workshop ( https://docs.google.com/document/d/1fuDLLb6TNPg_cBpCyQvBuwt3jqTehIgIjfffu3N4dEE/edit#heading=h.sbscbncuhxte), which might prove helpful. Here it's instructed to uncomment this line for the relaxation process.

Cheers, Taj

On Wed, 24 Apr 2024 at 03:57, Daniel Price @.***> wrote:

definitely most people have set up an isolated star followed by the moddump_tde procedure to place it in orbit. The one-stop setup_grtde procedure is new... I'm not sure what is going wrong here. In the meantime I'd suggest to fall back to the "regular" SETUP=grstar followed by moddump procedure if it's not working for you..

— Reply to this email directly, view it on GitHub https://github.com/danieljprice/phantom/issues/465#issuecomment-2073852414, or unsubscribe https://github.com/notifications/unsubscribe-auth/APQXJCM4MOXXYX4LPWBSKJDY64GRDAVCNFSM6AAAAAA4OTTYK6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZTHA2TENBRGQ . You are receiving this because you commented.Message ID: @.***>

Shigaharuki3012 commented 4 months ago

I'm not sure what the issue is here, you are in the GR code so you must have G=M=c=1 and the only unit freedom is to set the mass unit, typically we set M=1 for the black hole. Please clarify exactly what the problem is?

Is the problem you get NaNs on relaxing the star? If so exactly what parameters are needed to reproduce this?

Sorry for making the problem not so clear...I realized that was not a problem at all :) And thanks for @tajjankovic to reproduce the issue.

danieljprice commented 3 months ago

I tracked this down, it was broken in 09e337c1b2 . The solution is NOT to uncomment the relevant line in derivs.F90, as this would overwrite the conservative variables.

Fixed as outlined in #544 , namely by making sure prim2consall was called before undertaking stellar relaxation. This should not be done every time derivs is called.