-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulate_on_cluster.py
35 lines (28 loc) · 1.7 KB
/
simulate_on_cluster.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
__author__ = 'robert'
from CSimulation import CSimulation
from settings.settings import CSimulationData
from Logger.StandardLogger import CLoggerOfSimulation, add_logger_to_simulation
# constants:
frequency_logging = 10000 # How often should be logged?
path_for_logging = "/data/fg2/schwieger/data_evolution_of_choosiness/inSoup/" # Where the logged data should be saved
def simulate(settings_file ,number_of_timesteps, frequency_logging, path_for_logging):
# Create simulation object
settings = CSimulationData(settings_file)
simulation = CSimulation(settings=settings)
# initialize logger
logger_of_simulation = CLoggerOfSimulation(simulation=simulation, periodicity_of_logging=frequency_logging,
path=path_for_logging)
add_logger_to_simulation(simulation, logger_of_simulation) # connects the logger to the simulation
# Run the simulation
print("Simulation started.")
print("Compute now "+str(number_of_timesteps)+" iterations")
simulation.run_n_timesteps(number_of_timesteps)
logger_of_simulation.log_current_state_of_simulation()
print("Simulation is over.")
list_of_simulation_settings = [('settings/settings_comp_with_analytic1.txt', 500000),
('settings/settings_comp_with_analytic2.txt', 500000),
('settings/settings_comp_with_analytic3.txt', 500000),
('settings/settings_comp_with_analytic4.txt', 500000)]
for settings_file, number_of_iterations in list_of_simulation_settings:
simulate(settings_file=settings_file,number_of_timesteps=number_of_iterations, frequency_logging=frequency_logging,
path_for_logging=path_for_logging)