Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions SPiCE.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import processes


__version__ = "0.0.1-alpha"
__version__ = "0.0.2-alpha"


def get_class(base_module, class_name):
Expand All @@ -41,8 +41,11 @@ def read_config_file(self, name):
self.context = settings.validate(user_settings)

def __init__(self, config_file):
#The code crash with 'FloatingPointError' for the cases: "x/0", overflow, underflow and nan ("0/0" or "inf/inf")
np.seterr(divide='raise',over='raise',under='raise',invalid='raise')
if config_file is None:
config_file = 'model.yml.example'
config_file = 'gas_example.yml'

self.read_config_file(config_file)

self.phases = {}
Expand Down Expand Up @@ -72,17 +75,18 @@ def run(self):
timesteps_Gyr.append(phase.get_timestep_Gyr())
timestep_Gyr = np.nanmax([np.nanmin(timesteps_Gyr),
self.integrator['minimum_timestep_Gyr']])
#total_mass_sum= 0
for phase in self.phases.values():
# total_mass_sum += phase.current_mass_Msun()
phase.update_mass(timestep_Gyr)
#print(total_mass_sum)
self.time_Gyr.append(current_time_Gyr + timestep_Gyr)

def update_derivatives(self, term):
print("This should not happen!")
raise(-1)




if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="SPiCE",
Expand Down
67 changes: 67 additions & 0 deletions gas_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
imf: kroupa
binary_star_rates: 0.40
dtd_sn: rlp

integrator:
relative_accuracy: 1.0e-6
initial_time_Gyr: 0.
final_time_Gyr: 13.7
minimum_timestep_Gyr: 1.0e-4 #Should not be higher with the current integrator we have

phases:
gas_HII:
type: ionized_hydrogen
params:
initial_mass_Msun: 100.
initial_temperature_K: 1.0e4
initial_pressure_cgs: 1.38e-12 #erg/cm^3
gas_HI:
type: neutral_hydrogen
params:
initial_mass_Msun: 0.0
initial_temperature_K: 100.
initial_pressure_cgs: 1.38e-12 #erg/cm^3
gas_H2:
type: molecular_hydrogen
params:
initial_mass_Msun: 0.0
initial_temperature_K: 10.
initial_pressure_cgs: 1.38e-12 #erg/cm^3
stars:
type: star
params:
initial_mass_Msun: 0.0

processes:
star_formation:
type: timescale_constant
params:
input_phase: gas_H2
output_phase: stars
timescale_Gyr: 3.478
recombination:
type: H_recombination
params:
input_phase: gas_HII
output_phase: gas_HI
molecule_formation:
type: H2_formation
params:
input_phase: gas_HI
output_phase: gas_H2
agent_phase: gas_HII
metallicity: 0.02 #Placeholder! one should put something like 'agent_phase2: dust' or something for better models
photoionization:
type: basic_photoionization
params:
input_phase: gas_HI
output_phase: gas_HII
agent_phase: stars
efficiency: 955.29
photodissociation:
type: basic_photoionization
params:
input_phase: gas_H2
output_phase: gas_HI
agent_phase: stars
efficiency: 380.93
Loading