Repository navigation
Expand file tree
/
Copy pathXsdirEntry.python.cpp
More file actions
190 lines (164 loc) · 5.51 KB
/
Copy pathXsdirEntry.python.cpp
File metadata and controls
190 lines (164 loc) · 5.51 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// system includes
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
// local includes
#include "ACEtk/XsdirEntry.hpp"
// namespace aliases
namespace python = pybind11;
void wrapXsdirEntry( python::module& module, python::module& ) {
// type aliases
using Component = njoy::ACEtk::XsdirEntry;
// wrap views created by this component
// create the component
python::class_< Component > component(
module,
"XsdirEntry",
"An entry in an xsdir file\n\n"
"An xsdir entry consists of either 7, 10 or 11 values:\n"
" - the zaid\n"
" - the atomic mass ratio\n"
" - file name\n"
" - an access path (undefined path if \'0\')\n"
" - a file type (1 for ascii, 2 for binary)\n"
" - the starting address or line number\n"
" - the table length (number of words in the XSS array)\n"
" - the length of a record (0 for ascii files)\n"
" - the number of entries (0 for ascii files)\n"
" - the temperature in MeV\n"
" - ptable if the table has a probability table for the URR"
);
// wrap the component
component
.def(
python::init< std::string, double, std::string,
unsigned int, unsigned int, unsigned int,
std::optional< std::string >,
std::optional< unsigned int >,
std::optional< unsigned int >,
std::optional< double >,
bool >(),
python::arg( "zaid" ), python::arg( "awr" ), python::arg( "filename" ),
python::arg( "filetype" ), python::arg( "address" ),
python::arg( "length" ), python::arg( "access" ) = std::nullopt,
python::arg( "recordlength" ) = std::nullopt,
python::arg( "entries" ) = std::nullopt,
python::arg( "temperature" ) = std::nullopt,
python::arg( "ptable" ) = false,
"Initialise the component\n\n"
"Arguments:\n"
" self the xsdir entry\n"
" zaid the zaid\n"
" awr the atomic weight ratio (to the neutron mass)\n"
" filename the file name\n"
" address the starting address or line\n"
" length the length of the file\n"
" access the access path for the file (optional)\n"
" recordlength the length of a record (optional)\n"
" entries the number of entries per record (optional)\n"
" temperature the temperature of the file (optional)\n"
" ptable flag to indicate if a probability table is present"
)
.def(
python::init< std::string, double, std::string,
unsigned int, unsigned int,
std::optional< double >,
bool, std::optional< std::string > >(),
python::arg( "zaid" ), python::arg( "awr" ), python::arg( "filename" ),
python::arg( "address" ), python::arg( "length" ),
python::arg( "temperature" ) = std::nullopt,
python::arg( "ptable" ) = false,
python::arg( "access" ) = std::nullopt,
"Initialise the component\n\n"
"Arguments:\n"
" self the xsdir entry\n"
" zaid the zaid\n"
" awr the atomic weight ratio (to the neutron mass)\n"
" filename the file name\n"
" address the starting address or line\n"
" length the length of the file\n"
" temperature the temperature of the file (optional)\n"
" ptable flag to indicate if a probability table is present\n"
" access the access path for the file (optional)"
)
.def_property_readonly(
"zaid",
&Component::ZAID,
"The ZAID of the table"
)
.def_property_readonly(
"awr",
&Component::AWR,
"The atomic weight ratio (with respect to the neutron mass)"
)
.def_property_readonly(
"atomic_weight_ratio",
&Component::atomicWeightRatio,
"The atomic weight ratio (with respect to the neutron mass)"
)
.def_property_readonly(
"file_name",
&Component::fileName,
"The file name and path"
)
.def_property_readonly(
"access_route",
&Component::accessRoute,
"The access route"
)
.def_property_readonly(
"file_type",
&Component::fileType,
"The file type"
)
.def_property_readonly(
"address",
&Component::address,
"The table address or starting line"
)
.def_property_readonly(
"table_length",
&Component::tableLength,
"The table length"
)
.def_property_readonly(
"record_length",
&Component::recordLength,
"The record length (used for binary files only)"
)
.def_property_readonly(
"entries_per_record",
&Component::entriesPerRecord,
"The number of entries per record (used for binary files only)"
)
.def_property_readonly(
"temperature",
&Component::temperature,
"The temperature of the table (if it is defined)"
)
.def_property_readonly(
"ptable",
&Component::ptable,
"The flag indicating whether or not a probability table is present"
)
.def_static(
"from_string",
[] ( const std::string& string ) -> Component {
std::istringstream in( string );
return Component( in );
},
python::arg( "string" ),
"Read the xsdir entry from a string\n\n"
"An exception is raised if something goes wrong while reading the entry\n\n"
"Arguments:\n"
" string the string representing the xsdir entry"
)
.def(
"to_string",
[] ( const Component& self ) {
std::ostringstream out;
self.print( out );
return out.str();
},
"Return the string representation of the xsdir entry"
);
}