Class representing description of zones in Fluka input
Source code in yaptide/converter/converter/fluka/cards/region_card.py
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
36
37
38 | @dataclass
class RegionsCard:
"""Class representing description of zones in Fluka input"""
data: list[FlukaRegion] = field(default_factory=lambda: [])
def __str__(self) -> str:
"""Return the card as a string."""
result = ""
for index, region in enumerate(self.data):
if index == 0:
line = ""
else:
line = "\n"
line += f"{region.name} 5"
# The '5' is the NAZ value for the region
# From Fluka documentation:
# NAZ is a rough guess for the number of regions which can be entered
# leaving the current region, normally 5
for zone_index, zone in enumerate(region.figures_operators):
for operation, figure_name in zone:
if operation == BoolOperation.INTERSECTION:
line += f" +{figure_name}"
elif operation == BoolOperation.SUBTRACTION:
line += f" -{figure_name}"
if len(line) >= 120: # Ensure that line is not longer than 132 characters
result += line
line = "\n"
# We connect Fluka zones into regions with union operator
if zone_index < len(region.figures_operators) - 1:
line += " |"
result += line
return result
|
data
class-attribute
instance-attribute
data = field(default_factory=lambda: [])
__init__
__init__(data=lambda: []())
__str__
Return the card as a string.
Source code in yaptide/converter/converter/fluka/cards/region_card.py
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
36
37
38 | def __str__(self) -> str:
"""Return the card as a string."""
result = ""
for index, region in enumerate(self.data):
if index == 0:
line = ""
else:
line = "\n"
line += f"{region.name} 5"
# The '5' is the NAZ value for the region
# From Fluka documentation:
# NAZ is a rough guess for the number of regions which can be entered
# leaving the current region, normally 5
for zone_index, zone in enumerate(region.figures_operators):
for operation, figure_name in zone:
if operation == BoolOperation.INTERSECTION:
line += f" +{figure_name}"
elif operation == BoolOperation.SUBTRACTION:
line += f" -{figure_name}"
if len(line) >= 120: # Ensure that line is not longer than 132 characters
result += line
line = "\n"
# We connect Fluka zones into regions with union operator
if zone_index < len(region.figures_operators) - 1:
line += " |"
result += line
return result
|