Bases: Parser
A simple parser that parses only some of the parameters, such as geometry data and beam energy,
and returns hardcoded values for other parameters
Source code in yaptide/converter/converter/fluka/parser.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 | class FlukaParser(Parser):
"""
A simple parser that parses only some of the parameters, such as geometry data and beam energy,
and returns hardcoded values for other parameters
"""
def __init__(self) -> None:
super().__init__()
self.info["simulator"] = "fluka"
self.info["version"] = "unknown"
self.input = Input()
def parse_configs(self, json: dict) -> None:
"""Parse energy and number of particles from json."""
self.input.number_of_particles = json["beam"]["numberOfParticles"]
self.input.figures = parse_figures(json["figureManager"].get("figures"))
regions, world_figures = parse_regions(json["zoneManager"], self.input.figures)
self.input.scorings = parse_scorings(json["detectorManager"], json["scoringManager"])
self.input.regions = list(regions.values())
self.input.figures.extend(world_figures)
materials, compounds, self.input.lowmats = parse_materials(json["materialManager"]["materials"],
json["zoneManager"])
self.input.materials = [
material for material in materials.values() if material.fluka_name.startswith(("MAT", "COM"))
]
self.input.compounds = [compound for compound in compounds.values() if compound.fluka_name.startswith("COM")]
self.input.assignmats = assign_materials_to_regions(materials, regions, json["zoneManager"])
self.input.matprops = set_custom_ionisation_potential(materials, json["zoneManager"],
json["materialManager"]["materials"])
self.input.beam = parse_beam(json["beam"])
def get_configs_json(self) -> dict:
"""
Return a dict representation of the config files. Each element has
the config files name as key and its content as value.
"""
configs_json = super().get_configs_json()
configs_json["fl_sim.inp"] = str(self.input)
return configs_json
|
__init__
Source code in yaptide/converter/converter/fluka/parser.py
| def __init__(self) -> None:
super().__init__()
self.info["simulator"] = "fluka"
self.info["version"] = "unknown"
self.input = Input()
|
get_configs_json
Return a dict representation of the config files. Each element has
the config files name as key and its content as value.
Source code in yaptide/converter/converter/fluka/parser.py
45
46
47
48
49
50
51
52
53 | def get_configs_json(self) -> dict:
"""
Return a dict representation of the config files. Each element has
the config files name as key and its content as value.
"""
configs_json = super().get_configs_json()
configs_json["fl_sim.inp"] = str(self.input)
return configs_json
|
parse_configs
Parse energy and number of particles from json.
Source code in yaptide/converter/converter/fluka/parser.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 | def parse_configs(self, json: dict) -> None:
"""Parse energy and number of particles from json."""
self.input.number_of_particles = json["beam"]["numberOfParticles"]
self.input.figures = parse_figures(json["figureManager"].get("figures"))
regions, world_figures = parse_regions(json["zoneManager"], self.input.figures)
self.input.scorings = parse_scorings(json["detectorManager"], json["scoringManager"])
self.input.regions = list(regions.values())
self.input.figures.extend(world_figures)
materials, compounds, self.input.lowmats = parse_materials(json["materialManager"]["materials"],
json["zoneManager"])
self.input.materials = [
material for material in materials.values() if material.fluka_name.startswith(("MAT", "COM"))
]
self.input.compounds = [compound for compound in compounds.values() if compound.fluka_name.startswith("COM")]
self.input.assignmats = assign_materials_to_regions(materials, regions, json["zoneManager"])
self.input.matprops = set_custom_ionisation_potential(materials, json["zoneManager"],
json["materialManager"]["materials"])
self.input.beam = parse_beam(json["beam"])
|