-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsregion.py
119 lines (99 loc) · 4.08 KB
/
sregion.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
from regularregioncontainer import *
# from subregion import SubRegion
class SRegion(RegularRegionContainer):
"""
SREGION - Start of new s-region. Describes field and material properties.
Parameters:
1.1) SLEN (R) Length of this s region [m]
1.2) NRREG (I) # of radial subregions of this s region {1-4}
1.3) ZSTEP (R) step for tracking particles [m]
Note that for fixed-stepping the program may modify this value slightly to get
an integral number of steps in the region.
The following parameters are repeated for each r subregion:
2.1) IRREG (I) r-region number
2.2) RLOW (R) Inner radius of this r subregion[m]
2.3) RHIGH (R) Outer radius of this r subregion[m]
3) FTAG (A4) Tag identifying field in this r subregion
(See specific field type below)
4) FPARM (R) 15 parameters describing field (see specific field type below)
These 15 parameters must be on one input line.
5) MTAG (2A4) Tag identifying material composition in this r subregion
The wedge geometry can accept a second MTAG parameter.
The first material refers to the interior of the wedge.
The second material, if present, refers to the exterior of the wedge.
If a second MTAG parameter is not present, vacuum is assumed. (see specific material type below)
6) MGEOM (A6) Tag identifying material geometry in this r subregion.
(see specific material type below)
7) GPARM (R) 10 Parameters describing material geometry.
These 10 parameters must be on one input line (see specific material type below)
"""
allowed_enclosed_commands = ['SubRegion']
begtag = 'SREGION'
endtag = ''
num_params = 3
for001_format = {'line_splits': [3]}
command_params = {
'slen': {
'desc': 'Length of this s region [m]',
'doc': '',
'type': 'Real',
'req': True,
'pos': 1},
'nrreg': {
'desc': '# of radial subregions of this s region {1-4}',
'doc': '',
'type': 'Int',
'min': 1,
'max': 4,
'req': True,
'pos': 2},
'zstep': {
'desc': 'Step for tracking particles [m]',
'doc': '',
'type': 'Real',
'req': True,
'pos': 3},
#'outstep': {
# 'desc': 'Step for generating OUTPUT commands within SRegion.',
# 'doc': 'Will wrap SRegion in REPEAT/ENDREPEAT statements.',
# 'type': 'Real',
# 'req': False,
# 'pos': None}
}
def __init__(self, **kwargs):
RegularRegion.__init__(self, kwargs)
Container.__init__(self)
def __str__(self):
ret_str = 'SRegion:\n' + 'slen=' + str(self.slen) + '\n' + 'nrreg=' + str(self.nrreg) + '\n' + \
'zstep=' + str(self.zstep) + '\n' + str(Container.__str__(self))
return ret_str
def __repr__(self):
return 'SRegion:\n ' + 'slen=' + \
str(self.slen) + '\n' + 'nrreg=' + str(self.nrreg) + \
'\n' + 'zstep=' + str(self.zstep)
def __setattr__(self, name, value):
Container.__setattr__(self, name, value)
def add_subregion(self, subregion):
try:
if self.check_type('SubRegion', subregion):
if not hasattr(self, 'subregions'):
self.subregions = []
self.subregions.append(subregion)
else:
raise ie.InvalidType('SubRegion', subregion.__class__.__name__)
except ie.InvalidType as e:
print e
def add_subregions(self, subregion_list):
for subregion in subregion_list:
self.subregions.append(subregion)
"""def gen_for001(self, file):
if hasattr(self, 'outstep'):
sreg_copy = copy.deepcopy(self)
delattr(sreg_copy, 'outstep')
sreg_copy.slen = self.outstep
nrep = int(self.slen/self.outstep)
r = Repeat(nrep=nrep)
r.add_enclosed_command(sreg_copy)
r.gen_for001(file)
else:
RegularRegionContainer.gen_for001(self, file)"""