Thursday, April 16, 2015

GR1D Setup

[]

notes for 2015-04-09

Setup

cd ~/stellar_collapse/

wget http://www.tapir.caltech.edu/~cott/HIPACC2014/GR1D_HIPACC2014.tar.gz tar -xzvf GR1D_HIPACC2014.tar.gz

cd GR1D_HIPACC2014/ * edit make.inc to point to your fortran compiler make

cp sample_parameter_files/hybrid_collapse.param parameters

Running

Now I've run with the default parameters.

./GR1D

the directory Data has two kinds of files .dat and .xg

In [1]:
%cd ~/programs/stellar_collapse/GR1D_HIPACC2014/
!ls
/home/arno/programs/stellar_collapse/GR1D_HIPACC2014
Data  docs  GR1D  Makefile  make.inc  parameters  profiles  sample_parameter_files  src

In [2]:
%cd Data/
!ls
/home/arno/programs/stellar_collapse/GR1D_HIPACC2014/Data
accreted_mass.dat   csound_c_t.dat  mass_grav.xg      mgrav_shock.dat  press.xg      shock_radius_t.dat  v1.xg     ye_c_t.dat
accretion_rates.dat   cs.xg    mbary_rho1e12.dat  mgrav_Xmax.dat   rho_c_t.dat    tbounce.dat  volume.xg  ye.xg
alpha_c_t.dat    eps_kin.xg   mbary_shock.dat    M_innercore.dat  rho.xg      time_c.dat   v.xg
alpha.xg    eps.xg   mbary_Xmax.dat     parameters       r_rho1e12.dat  timers.dat   W.xg
binding_energy_total.dat  mass_bary.xg   mgrav_rho1e12.dat  pressth.xg       r_Xmax.dat     totalmass.dat  X.xg

.dat files have the format:

[radius] [value]

.xg files have the format:

"Time = [time]

[radius] [value]

In [3]:
def get_XG_data(varfile):
    the_file = open(varfile, "r")
    
    var = []
    TIME = 0
    
    for line in the_file:
        if not line.strip():
            continue
        
        try:
            radius, value = line.split()
            var.append([TIME, radius, value])
        except ValueError:
            *rest, time = line.split()
            TIME = time
        except:
            print("Something really awful happened")
            raise
    
    the_file.close()
    
    return var
In [4]:
rho = get_XG_data("rho.xg")
In [5]:
len(rho)
Out[5]:
373968
In [6]:
import math
In [7]:
r = []
v = []
for time, radius, value in rho:
    if float(time) == 0:
        r.append(float(radius))
        v.append(math.log10(float(value)))
In [8]:
len(r), len(v)
Out[8]:
(1008, 1008)
In [9]:
%matplotlib inline
import matplotlib.pyplot as plt
In [10]:
plt.plot(r,v, color = "red")
Out[10]:
[<matplotlib.lines.Line2D at 0x7f4612baa6a0>]
In [10]: