ray simulations seem to work

nodes (except head node) can deconnect and reconnect to/from the cluster and work is rebalanced properly. if a node dies while simulating, the leftover work is picked up at the end and everything is merged normall. Tests of the actual validity of the mergd data have not been made yet
This commit is contained in:
Benoît Sierro
2021-02-01 09:05:44 +01:00
parent 15bc736294
commit 3c2e98d1e9
37 changed files with 283 additions and 372 deletions

View File

@@ -17,7 +17,7 @@ width = 50e-15
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = false
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -7,12 +7,13 @@ model = "marcatili"
gas_name = "air"
[pulse]
power = 100e3
wavelength = 800e-9
width = 250e-15
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
repeat = 1
t_num = 16384
time_window = 37e-12

View File

@@ -0,0 +1,23 @@
[fiber]
core_radius = 50e-6
length = 50e-2
model = "marcatili"
[gas]
gas_name = "air"
[pulse]
power = 100e3
wavelength = 800e-9
[pulse.varying]
width = [250e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = true
repeat = 1
t_num = 16384
time_window = 37e-12
tolerated_error = 1e-11
z_num = 128

View File

@@ -7,12 +7,13 @@ model = "marcatili"
gas_name = "air"
[pulse]
power = 100e3
wavelength = 800e-9
width = 250e-15
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
repeat = 2
t_num = 16384
time_window = 37e-12

View File

@@ -7,6 +7,7 @@ model = "marcatili"
gas_name = "air"
[pulse]
soliton_num = 5
wavelength = 800e-9
width = 250e-15
@@ -15,7 +16,7 @@ shape = ["gaussian", "sech"]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
repeat = 1
t_num = 16384
time_window = 37e-12

View File

@@ -20,7 +20,7 @@ intensity_noise = [0.05e-2, 0.1e-2]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -20,7 +20,7 @@ soliton_num = [1, 2, 3, 4]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -21,7 +21,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -22,7 +22,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -23,7 +23,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -22,7 +22,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -20,7 +20,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -21,7 +21,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
repeat = 4
t_num = 16384
time_window = 37e-12

View File

@@ -19,7 +19,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -29,7 +29,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -20,7 +20,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -22,7 +22,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -24,7 +24,7 @@ wavelength = [835e-9, 830e-9]
[simulation]
dt = 1e-15
parallel = 3
parallel = true
raman_type = "measured"
repeat = 4
t_num = 16384

View File

@@ -21,7 +21,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -21,7 +21,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss", "q_noise"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -21,7 +21,7 @@ width = ["gaussian", "sech"]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -29,4 +29,4 @@ tolerated_error = 1e-11
z_num = 1
[simulation.varying]
parallel = [2, 4]
parallel = [true, false]

View File

@@ -21,7 +21,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -21,7 +21,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 0
t_num = 16384

View File

@@ -19,7 +19,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -19,7 +19,7 @@ width = [50e-15, 100e-15, 200e-15]
[simulation]
behaviors = ["spm", "raman", "ss"]
parallel = 2
parallel = true
raman_type = "agrawal"
repeat = 4
t_num = 16384

View File

@@ -22,33 +22,33 @@ class TestInitializeMethods(unittest.TestCase):
def test_validate_types(self):
conf = lambda s: load_conf("validate_types/" + s)
with self.assertRaisesRegex(TypeError, "belong"):
init.validate_types(conf("bad1"))
init._validate_types(conf("bad1"))
with self.assertRaisesRegex(TypeError, "valid list of behaviors"):
init.validate_types(conf("bad2"))
init._validate_types(conf("bad2"))
with self.assertRaisesRegex(TypeError, "single, real, non-negative number"):
init.validate_types(conf("bad3"))
init._validate_types(conf("bad3"))
with self.assertRaisesRegex(TypeError, "'parallel' is not a valid variable parameter"):
init.validate_types(conf("bad4"))
init._validate_types(conf("bad4"))
with self.assertRaisesRegex(TypeError, "Varying parameters should be specified in a list"):
init.validate_types(conf("bad5"))
init._validate_types(conf("bad5"))
with self.assertRaisesRegex(
TypeError,
"value '0' of type <class 'int'> for key 'repeat' is not valid, must be a strictly positive integer",
):
init.validate_types(conf("bad6"))
init._validate_types(conf("bad6"))
with self.assertRaisesRegex(
ValueError,
r"Varying parameters lists should contain at least 1 element",
):
init.ensure_consistency(conf("bad7"))
init._ensure_consistency(conf("bad7"))
self.assertIsNone(init.validate_types(conf("good")))
self.assertIsNone(init._validate_types(conf("good")))
def test_ensure_consistency(self):
conf = lambda s: load_conf("ensure_consistency/" + s)
@@ -56,68 +56,68 @@ class TestInitializeMethods(unittest.TestCase):
MissingParameterError,
r"1 of '\['t0', 'width'\]' is required and no defaults have been set",
):
init.ensure_consistency(conf("bad1"))
init._ensure_consistency(conf("bad1"))
with self.assertRaisesRegex(
MissingParameterError,
r"1 of '\['power', 'energy', 'width', 't0'\]' is required when 'soliton_num' is specified and no defaults have been set",
):
init.ensure_consistency(conf("bad2"))
init._ensure_consistency(conf("bad2"))
with self.assertRaisesRegex(
MissingParameterError,
r"2 of '\['dt', 't_num', 'time_window'\]' are required and no defaults have been set",
):
init.ensure_consistency(conf("bad3"))
init._ensure_consistency(conf("bad3"))
with self.assertRaisesRegex(
DuplicateParameterError,
r"got multiple values for parameter 'width'",
):
init.ensure_consistency(conf("bad4"))
init._ensure_consistency(conf("bad4"))
with self.assertRaisesRegex(
MissingParameterError,
r"'capillary_thickness' is a required parameter for fiber model 'hasan' and no defaults have been set",
):
init.ensure_consistency(conf("bad5"))
init._ensure_consistency(conf("bad5"))
with self.assertRaisesRegex(
MissingParameterError,
r"1 of '\['capillary_spacing', 'capillary_outer_d'\]' is required for fiber model 'hasan' and no defaults have been set",
):
init.ensure_consistency(conf("bad6"))
init._ensure_consistency(conf("bad6"))
self.assertLessEqual(
{"model": "pcf"}.items(), init.ensure_consistency(conf("good1"))["fiber"].items()
{"model": "pcf"}.items(), init._ensure_consistency(conf("good1"))["fiber"].items()
)
self.assertNotIn("gas", init.ensure_consistency(conf("good1")))
self.assertNotIn("gas", init._ensure_consistency(conf("good1")))
self.assertNotIn("gamma", init.ensure_consistency(conf("good4"))["fiber"])
self.assertNotIn("gamma", init._ensure_consistency(conf("good4"))["fiber"])
self.assertLessEqual(
{"raman_type": "agrawal"}.items(),
init.ensure_consistency(conf("good2"))["simulation"].items(),
init._ensure_consistency(conf("good2"))["simulation"].items(),
)
self.assertLessEqual(
{"name": "no name"}.items(), init.ensure_consistency(conf("good3")).items()
{"name": "no name"}.items(), init._ensure_consistency(conf("good3")).items()
)
self.assertLessEqual(
{"capillary_nested": 0, "capillary_resonance_strengths": []}.items(),
init.ensure_consistency(conf("good4"))["fiber"].items(),
init._ensure_consistency(conf("good4"))["fiber"].items(),
)
self.assertLessEqual(
dict(he_mode=(1, 1)).items(),
init.ensure_consistency(conf("good5"))["fiber"].items(),
init._ensure_consistency(conf("good5"))["fiber"].items(),
)
self.assertLessEqual(
dict(temperature=300, pressure=1e5, gas_name="vacuum", plasma_density=0).items(),
init.ensure_consistency(conf("good5"))["gas"].items(),
init._ensure_consistency(conf("good5"))["gas"].items(),
)
self.assertLessEqual(
@@ -127,29 +127,14 @@ class TestInitializeMethods(unittest.TestCase):
lower_wavelength_interp_limit=0,
upper_wavelength_interp_limit=1900e-9,
).items(),
init.ensure_consistency(conf("good6"))["simulation"].items(),
init._ensure_consistency(conf("good6"))["simulation"].items(),
)
def test_single_sim(self):
conf = conf_maker("single_sim")
self.assertTrue(init.single_sim(conf("true1")))
self.assertFalse(init.single_sim(conf("false1")))
self.assertFalse(init.single_sim(conf("false2")))
# def test_compute_init_parameters(self):
# conf = lambda s: load_conf("compute_init_parameters/" + s)
if __name__ == "__main__":
conf = conf_maker("validate_types")
config = conf("good")
pprint(config)
config = init.ensure_consistency(config)
pprint(config)
params = init.compute_init_parameters(config)
pprint(params)
unittest.main()

30
testing/test_utils.py Normal file
View File

@@ -0,0 +1,30 @@
import unittest
from scgenerator import utils, initialize
import toml
def load_conf(name):
with open("testing/configs/" + name + ".toml") as file:
conf = toml.load(file)
return conf
def conf_maker(folder):
def conf(name):
return initialize.validate(load_conf(folder + "/" + name))
return conf
class TestUtilsMethods(unittest.TestCase):
def test_count_variations(self):
conf = conf_maker("count_variations")
self.assertEqual((1, 0), utils.count_variations(conf("1sim_0vary")))
self.assertEqual((1, 1), utils.count_variations(conf("1sim_1vary")))
self.assertEqual((2, 1), utils.count_variations(conf("2sim_1vary")))
self.assertEqual((2, 0), utils.count_variations(conf("2sim_0vary")))
if __name__ == "__main__":
unittest.main()