Skip to content
Snippets Groups Projects
Commit be0074a1 authored by lhausamm's avatar lhausamm
Browse files

Remove config.h parsing

parent 743713e3
No related branches found
No related tags found
1 merge request!486Add chemistry in part
...@@ -33,24 +33,13 @@ P = 1. # Pressure ...@@ -33,24 +33,13 @@ P = 1. # Pressure
gamma = 5./3. # Gas adiabatic index gamma = 5./3. # Gas adiabatic index
fileName = "input.hdf5" fileName = "input.hdf5"
# read flags from config.h
flags = {}
config_file = "../config.h"
with open(config_file, "r") as f:
reg = "#define (\w*) (.*)\n"
for line in f:
m = regex.match(reg, line)
if m:
flags[m.group(1)] = m.group(2)
cooling_grackle = "COOLING_GRACKLE" in flags
#--------------------------------------------------- #---------------------------------------------------
numPart = L**3 numPart = L**3
mass = boxSize**3 * rho / numPart mass = boxSize**3 * rho / numPart
internalEnergy = P / ((gamma - 1.)*rho) internalEnergy = P / ((gamma - 1.)*rho)
if cooling_grackle:
he_density = rho * 0.24 # chemistry data
he_density = rho * 0.24
#Generate particles #Generate particles
coords = zeros((numPart, 3)) coords = zeros((numPart, 3))
...@@ -59,8 +48,9 @@ m = zeros((numPart, 1)) ...@@ -59,8 +48,9 @@ m = zeros((numPart, 1))
h = zeros((numPart, 1)) h = zeros((numPart, 1))
u = zeros((numPart, 1)) u = zeros((numPart, 1))
ids = zeros((numPart, 1), dtype='L') ids = zeros((numPart, 1), dtype='L')
if cooling_grackle:
he = zeros((numPart, 1)) # chemistry data
he = zeros((numPart, 1))
for i in range(L): for i in range(L):
for j in range(L): for j in range(L):
...@@ -79,8 +69,8 @@ for i in range(L): ...@@ -79,8 +69,8 @@ for i in range(L):
h[index] = 2.251 * boxSize / L h[index] = 2.251 * boxSize / L
u[index] = internalEnergy u[index] = internalEnergy
ids[index] = index ids[index] = index
if cooling_grackle: # chemistry data
he[index] = he_density he[index] = he_density
#-------------------------------------------------- #--------------------------------------------------
...@@ -127,8 +117,8 @@ ds = grp.create_dataset('InternalEnergy', (numPart,1), 'f') ...@@ -127,8 +117,8 @@ ds = grp.create_dataset('InternalEnergy', (numPart,1), 'f')
ds[()] = u ds[()] = u
ds = grp.create_dataset('ParticleIDs', (numPart, 1), 'L') ds = grp.create_dataset('ParticleIDs', (numPart, 1), 'L')
ds[()] = ids ds[()] = ids
if cooling_grackle: # chemistry
ds = grp.create_dataset('HeDensity', (numPart, 1), 'f') ds = grp.create_dataset('HeDensity', (numPart, 1), 'f')
ds[()] = he ds[()] = he
file.close() file.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment