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
In [2]:
%cd Data/
!ls
.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]:
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]:
In [9]:
%matplotlib inline
import matplotlib.pyplot as plt
In [10]:
plt.plot(r,v, color = "red")
Out[10]:
In [10]:
No comments:
Post a Comment