pymchelper.flair package#
Subpackages#
- pymchelper.flair.common package
- Submodules
- pymchelper.flair.common.bmath module
Cmp0()
DefaultDict
Matrix
Matrix.O
Matrix.T()
Matrix.U
Matrix.append()
Matrix.clone()
Matrix.det()
Matrix.determinant()
Matrix.diagonal()
Matrix.eulerRotation()
Matrix.getEulerRotation()
Matrix.inv()
Matrix.inverse()
Matrix.make()
Matrix.multNoTranslation()
Matrix.rotX()
Matrix.rotY()
Matrix.rotZ()
Matrix.rotate()
Matrix.scale()
Matrix.trace()
Matrix.translate()
Matrix.transpose()
Matrix.unary()
Matrix.writeOctave()
Matrix.zero()
Quaternion
Vector
Vector.O
Vector.X
Vector.Y
Vector.Z
Vector.arg()
Vector.clone()
Vector.cosTheta()
Vector.cross()
Vector.direction()
Vector.dot()
Vector.eq()
Vector.length()
Vector.length2()
Vector.norm()
Vector.normalize()
Vector.orthogonal()
Vector.perp()
Vector.perp2()
Vector.phi()
Vector.set()
Vector.setPolar()
Vector.theta()
Vector.unit()
Vector.x()
Vector.y()
Vector.z()
ZeroDict
ZeroIntDict
cubic()
d2s()
dms()
eigenvalues()
fitPlane()
format_number()
frange()
gauss()
goldenSectionSearch()
int2roman()
limit()
linear()
polar()
polyderiv()
polyeval()
polyreduce()
quadratic()
random3D()
rect()
rndColor()
roman2int()
solveOverDetermined()
xcombinations()
xpermutations()
xselections()
xuniqueCombinations()
- pymchelper.flair.common.csg module
- pymchelper.flair.common.fortran module
- pymchelper.flair.common.log module
- pymchelper.flair.common.rexx module
- Module contents
Submodules#
pymchelper.flair.Data module#
pymchelper.flair.Input module#
- class pymchelper.flair.Input.Card(tag, what=None, comment='', extra='')[source]#
Bases:
object
Base class for a fluka card
- BODY = 1#
- GENERIC = 0#
- OBJECT = 3#
- REGION = 2#
- bodyP1()#
Position of body
- diff(card)[source]#
Return differences of the two cards as a list of integers -3 = enable/disable -2 = Comment -1 = Extra 0 = Sdum 1..n = What’s :param card: :return:
- get(t=None, default=None)#
get card information
- name()#
- set(t, v)#
set value to what(#, sdum, comment, extra)
- setName(s)#
set sdum
- test(func, var, val, case=False)[source]#
test card against a filter-function Filter format type [function]
what value
- func: [type][function]
- type: i=int
f=float s=string
- function:
a=abs
- var:
- 0..9 = whats
= anywhere
b = body d = detector s = sdum
m = material p = particle (range if tuple) r = region (range if tuple)
- t = transformation
u = unit
- param func:
- param var:
- param val:
anything int, float or string
- param case:
True for matching case
- return:
- class pymchelper.flair.Input.CardInfo(name, group, range_, extra, assert_, default, meaning)[source]#
Bases:
object
- static compileAssert(assertStatement)[source]#
Compile assert statement First detect all what references w(#) and replace them with:
w(#) -> c.numWhat(#) W(#) -> c.what(#)
identify all what-indexes to report as problems and request in the code that are not zero!
finally compile the code example: w(8)>w(7)
lambda c: c.numWhat(7)==0 or c.numWhat(8)==0 or c.numWhat(8)>c.numWhat(7)
- Parameters:
assertStatement
- Returns:
- class pymchelper.flair.Input.Input(filename=None)[source]#
Bases:
object
- addCard(card, pos=None, renumber=False)[source]#
Add a card to list at position pos WARNING: renumber is False (on contrast with delCard, moveCard) :param card: :param pos: :param renumber: :return:
- addCardProperty(tag, proptag, prop, valueWhat, fromWhat, toWhat=-1, stepWhat=-1, sdum=None, func=None)[source]#
Append to card’s properties the additional value from tag’s :param tag: cards to append the extra property :param proptag: cards from where to get the property :param prop: property name to add in cards :param valueWhat: which value to add as property :param fromWhat: range of cards :param toWhat: range of cards :param stepWhat: range of cards :param sdum: filter cards with the specific sdum :param func: apply a function to value :return:
- bestPosition(tag)[source]#
Find best position from the sorting order in the file search which card is closer to one we’ve asked :param tag: :return:
- bodyProperties()[source]#
Return the body properties as a dictionary of the active/enabled bodies :return:
- cardsSorted(tag, which=0)[source]#
Return cards of a specific tag sorted with _pos Possibilities on which:
0: enabled and active (requires a call to preprocess before) 1: enabled 2: all
Warning on REGION maybe the “&” you want to get rid off :param tag: :param which: :return:
- getTransformation(idx=None, rotdefi=None, inv=False)[source]#
FIXME I should combine the rotdefi with the self.cache! :param idx: rotation to return, Can be prefixed with “-”, None to return a dictionary :param rotdefi: cached dictionary :param inv: return the inverse of the idx matrix. Accepted even if idx is prefixed with “-” :return: rotation matrix from a rot-defi cards or a dictionary with all transformations
- include(includecard)[source]#
include card has been modified take appropriate action :param includecard: :return: True if #include has modified the input, False if nothing happened
- preprocess(activeDefines=None)[source]#
Pre-process all cards and set correspondingly the card.active flag nest[] contains the evaluation of the nesting -1: inactive - do not include any subsequent #if..
0: false & active - include substitute #if.. 1: true & active 2: false & active after else 3: true & active after else
FIXME values do not WORK! :param activeDefines: :return: list of error cards
- regionProperties()[source]#
Return the region properties as a dictionary of the active/enabled regions :return:
- renumber(fromPos=0, toPos=-1)[source]#
Put the correct index to cards in the range given by fromPos:toPos
- write(filename, backup=True)[source]#
Open and write the input to file (specified either by filename, or by file pointer). Optionally use a different geometry file and a different format
- writeCards(f, condition, format=None, geolevel=0, from_=0, to_=-1)[source]#
Write cards of that fulfill a given condition(lambda) with all the preprocessor cards around them FIXME Write also non empty blocks: #if .. #define/#undef .. #endif
Might end up in duplicate blocks when only #define/#undef exist inside the geometry
- geolevel
- -1 before defines
0 before geobegin 1 bodies and voxels 2 regions 3 lattices 4 after geoend
from_ .. to_ (to_ is not included) :param f: :param condition: :param format: :param geolevel: :param from_: :param to_: :return:
- class pymchelper.flair.Input.Particle(id, name, mass=0.0, comment=None, pdg=None)[source]#
Bases:
object
- beam = ['', '3-HELIUM', '4-HELIUM', 'AKAONZER', 'ALAMBDA', 'ALAMBDC-', 'ANEUTRIE', 'ANEUTRIM', 'ANEUTRIT', 'ANEUTRON', 'AOMEGA+', 'AOMEGAC0', 'APROTON', 'ASIGMA+', 'ASIGMA-', 'ASIGMAZE', 'AXSI+', 'AXSIC-', 'AXSIC0', 'AXSIPC-', 'AXSIPC0', 'AXSIZERO', 'D+', 'D-', 'D0', 'D0BAR', 'DEUTERON', 'DS+', 'DS-', 'ELECTRON', 'HEAVYION', 'ISOTOPE', 'KAON+', 'KAON-', 'KAONLONG', 'KAONSHRT', 'KAONZERO', 'LAMBDA', 'LAMBDAC+', 'MUON+', 'MUON-', 'NEUTRIE', 'NEUTRIM', 'NEUTRIT', 'NEUTRON', 'OMEGA-', 'OMEGAC0', 'OPTIPHOT', 'PHOTON', 'PION+', 'PION-', 'PIZERO', 'POSITRON', 'PROTON', 'RAY', 'SIGMA+', 'SIGMA-', 'SIGMAZER', 'TAU+', 'TAU-', 'TRITON', 'WWLOWNEU', 'XSI-', 'XSIC+', 'XSIC0', 'XSIPC+', 'XSIPC0', 'XSIZERO']#
- static convert(pid, tonames=True)[source]#
Convert particle from name to number particle type :param tonames: True/False :return:
- list = ['', '3-HELIUM', '4-HELIUM', 'AKAONZER', 'ALAMBDA', 'ALAMBDC-', 'ANEUTRIE', 'ANEUTRIM', 'ANEUTRIT', 'ANEUTRON', 'AOMEGA+', 'AOMEGAC0', 'APROTON', 'ASIGMA+', 'ASIGMA-', 'ASIGMAZE', 'AXSI+', 'AXSIC-', 'AXSIC0', 'AXSIPC-', 'AXSIPC0', 'AXSIZERO', 'D+', 'D-', 'D0', 'D0BAR', 'DEUTERON', 'DS+', 'DS-', 'ELECTRON', 'HEAVYION', 'KAON+', 'KAON-', 'KAONLONG', 'KAONSHRT', 'KAONZERO', 'LAMBDA', 'LAMBDAC+', 'MUON+', 'MUON-', 'NEUTRIE', 'NEUTRIM', 'NEUTRIT', 'NEUTRON', 'OMEGA-', 'OMEGAC0', 'OPTIPHOT', 'PHOTON', 'PION+', 'PION-', 'PIZERO', 'POSITRON', 'PROTON', 'RAY', 'SIGMA+', 'SIGMA-', 'SIGMAZER', 'TAU+', 'TAU-', 'TRITON', 'WWLOWNEU', 'XSI-', 'XSIC+', 'XSIC0', 'XSIPC+', 'XSIPC0', 'XSIZERO', '@LASTPAR']#
- listAll = ['', '3-HELIUM', '4-HELIUM', 'ACTIVITY', 'ACTOMASS', 'AKAONZER', 'ALAMBDA', 'ALAMBDC-', 'ALL-CHAR', 'ALL-IONS', 'ALL-NEGA', 'ALL-NEUT', 'ALL-PART', 'ALL-POSI', 'ALPHA-D', 'ANEUTRIE', 'ANEUTRIM', 'ANEUTRIT', 'ANEUTRON', 'ANNIHRST', 'AOMEGA+', 'AOMEGAC0', 'AP&AN', 'APROTON', 'ASIGMA+', 'ASIGMA-', 'ASIGMAZE', 'AXSI+', 'AXSIC-', 'AXSIC0', 'AXSIPC-', 'AXSIPC0', 'AXSIZERO', 'BEAMPART', 'C-(A)BAR', 'C-MESONS', 'CHARMED', 'D+', 'D-', 'D0', 'D0BAR', 'DEUTERON', 'DOSE', 'DOSE-EM', 'DOSE-EQ', 'DOSE-H2O', 'DOSEQLET', 'DPA-NRES', 'DPA-SCO', 'DS+', 'DS-', 'E+&E-', 'E+E-GAMM', 'ELECTRON', 'EM-ENRGY', 'ENERGY', 'FISSIONS', 'HAD-CHAR', 'HAD-NEUT', 'HADGT20M', 'HE-FISS', 'HEAVYION', 'HEHAD-EQ', 'HVY-IONS', 'ISOTOPE', 'KAON+', 'KAON-', 'KAONLONG', 'KAONS', 'KAONS+-', 'KAONS0', 'KAONSHRT', 'KAONZERO', 'LAMBDA', 'LAMBDAC+', 'LE-FISS', 'LGH-IONS', 'LOWENNEU', 'MUON+', 'MUON-', 'MUONS', 'NET-CHRG', 'NEU-BALA', 'NEUTRIE', 'NEUTRIM', 'NEUTRIT', 'NEUTRON', 'NIEL-DEP', 'NTLOWENE', 'NUC&PI+-', 'NUCLEONS', 'OMEGA-', 'OMEGAC0', 'OPTIPHOT', 'PHOTON', 'PION+', 'PION-', 'PIONS+-', 'PIZERO', 'POSITRON', 'PROTON', 'RAY', 'RES-NIEL', 'RES-NUCL', 'SI1MEVNE', 'SIGMA+', 'SIGMA-', 'SIGMAZER', 'SQBETA-D', 'STRANGE', 'TAU+', 'TAU-', 'THNEU-EQ', 'TRITON', 'UNB-EMEN', 'UNB-ENER', 'WWLOWNEU', 'X-MOMENT', 'XSI-', 'XSIC+', 'XSIC0', 'XSIPC+', 'XSIPC0', 'XSIZERO', 'Y-MOMENT', 'Z-MOMENT', '@LASTPAR']#
- particles = ['', '3-HELIUM', '4-HELIUM', 'AKAONZER', 'ALAMBDA', 'ALAMBDC-', 'ALL-CHAR', 'ALL-NEGA', 'ALL-NEUT', 'ALL-PART', 'ALL-POSI', 'ANEUTRIE', 'ANEUTRIM', 'ANEUTRIT', 'ANEUTRON', 'AOMEGA+', 'AOMEGAC0', 'AP&AN', 'APROTON', 'ASIGMA+', 'ASIGMA-', 'ASIGMAZE', 'AXSI+', 'AXSIC-', 'AXSIC0', 'AXSIPC-', 'AXSIPC0', 'AXSIZERO', 'BEAMPART', 'C-(A)BAR', 'C-MESONS', 'CHARMED', 'D+', 'D-', 'D0', 'D0BAR', 'DEUTERON', 'DS+', 'DS-', 'E+&E-', 'ELECTRON', 'HAD-CHAR', 'HAD-NEUT', 'HEAVYION', 'KAON+', 'KAON-', 'KAONLONG', 'KAONS', 'KAONS+-', 'KAONS0', 'KAONSHRT', 'KAONZERO', 'LAMBDA', 'LAMBDAC+', 'MUON+', 'MUON-', 'MUONS', 'NEUTRIE', 'NEUTRIM', 'NEUTRIT', 'NEUTRON', 'NUC&PI+-', 'NUCLEONS', 'OMEGA-', 'OMEGAC0', 'OPTIPHOT', 'PHOTON', 'PION+', 'PION-', 'PIONS+-', 'PIZERO', 'POSITRON', 'PROTON', 'RAY', 'SIGMA+', 'SIGMA-', 'SIGMAZER', 'STRANGE', 'TAU+', 'TAU-', 'TRITON', 'WWLOWNEU', 'XSI-', 'XSIC+', 'XSIC0', 'XSIPC+', 'XSIPC0', 'XSIZERO']#
- signedList = ['', '3-HELIUM', '-3-HELIUM', '4-HELIUM', '-4-HELIUM', 'AKAONZER', '-AKAONZER', 'ALAMBDA', '-ALAMBDA', 'ALAMBDC-', '-ALAMBDC-', 'ANEUTRIE', '-ANEUTRIE', 'ANEUTRIM', '-ANEUTRIM', 'ANEUTRIT', '-ANEUTRIT', 'ANEUTRON', '-ANEUTRON', 'AOMEGA+', '-AOMEGA+', 'AOMEGAC0', '-AOMEGAC0', 'APROTON', '-APROTON', 'ASIGMA+', '-ASIGMA+', 'ASIGMA-', '-ASIGMA-', 'ASIGMAZE', '-ASIGMAZE', 'AXSI+', '-AXSI+', 'AXSIC-', '-AXSIC-', 'AXSIC0', '-AXSIC0', 'AXSIPC-', '-AXSIPC-', 'AXSIPC0', '-AXSIPC0', 'AXSIZERO', '-AXSIZERO', 'D+', '-D+', 'D-', '-D-', 'D0', '-D0', 'D0BAR', '-D0BAR', 'DEUTERON', '-DEUTERON', 'DS+', '-DS+', 'DS-', '-DS-', 'ELECTRON', '-ELECTRON', 'HEAVYION', '-HEAVYION', 'KAON+', '-KAON+', 'KAON-', '-KAON-', 'KAONLONG', '-KAONLONG', 'KAONSHRT', '-KAONSHRT', 'KAONZERO', '-KAONZERO', 'LAMBDA', '-LAMBDA', 'LAMBDAC+', '-LAMBDAC+', 'MUON+', '-MUON+', 'MUON-', '-MUON-', 'NEUTRIE', '-NEUTRIE', 'NEUTRIM', '-NEUTRIM', 'NEUTRIT', '-NEUTRIT', 'NEUTRON', '-NEUTRON', 'OMEGA-', '-OMEGA-', 'OMEGAC0', '-OMEGAC0', 'OPTIPHOT', '-OPTIPHOT', 'PHOTON', '-PHOTON', 'PION+', '-PION+', 'PION-', '-PION-', 'PIZERO', '-PIZERO', 'POSITRON', '-POSITRON', 'PROTON', '-PROTON', 'RAY', '-RAY', 'SIGMA+', '-SIGMA+', 'SIGMA-', '-SIGMA-', 'SIGMAZER', '-SIGMAZER', 'TAU+', '-TAU+', 'TAU-', '-TAU-', 'TRITON', '-TRITON', 'WWLOWNEU', '-WWLOWNEU', 'XSI-', '-XSI-', 'XSIC+', '-XSIC+', 'XSIC0', '-XSIC0', 'XSIPC+', '-XSIPC+', 'XSIPC0', '-XSIPC0', 'XSIZERO', '-XSIZERO', '@LASTPAR']#
- signedListAll = ['', '3-HELIUM', '-3-HELIUM', '4-HELIUM', '-4-HELIUM', 'ACTIVITY', '-ACTIVITY', 'ACTOMASS', '-ACTOMASS', 'AKAONZER', '-AKAONZER', 'ALAMBDA', '-ALAMBDA', 'ALAMBDC-', '-ALAMBDC-', 'ALL-CHAR', '-ALL-CHAR', 'ALL-IONS', '-ALL-IONS', 'ALL-NEGA', '-ALL-NEGA', 'ALL-NEUT', '-ALL-NEUT', 'ALL-PART', '-ALL-PART', 'ALL-POSI', '-ALL-POSI', 'ALPHA-D', '-ALPHA-D', 'ANEUTRIE', '-ANEUTRIE', 'ANEUTRIM', '-ANEUTRIM', 'ANEUTRIT', '-ANEUTRIT', 'ANEUTRON', '-ANEUTRON', 'ANNIHRST', '-ANNIHRST', 'AOMEGA+', '-AOMEGA+', 'AOMEGAC0', '-AOMEGAC0', 'AP&AN', '-AP&AN', 'APROTON', '-APROTON', 'ASIGMA+', '-ASIGMA+', 'ASIGMA-', '-ASIGMA-', 'ASIGMAZE', '-ASIGMAZE', 'AXSI+', '-AXSI+', 'AXSIC-', '-AXSIC-', 'AXSIC0', '-AXSIC0', 'AXSIPC-', '-AXSIPC-', 'AXSIPC0', '-AXSIPC0', 'AXSIZERO', '-AXSIZERO', 'BEAMPART', '-BEAMPART', 'C-(A)BAR', '-C-(A)BAR', 'C-MESONS', '-C-MESONS', 'CHARMED', '-CHARMED', 'D+', '-D+', 'D-', '-D-', 'D0', '-D0', 'D0BAR', '-D0BAR', 'DEUTERON', '-DEUTERON', 'DOSE', '-DOSE', 'DOSE-EM', '-DOSE-EM', 'DOSE-EQ', '-DOSE-EQ', 'DOSE-H2O', '-DOSE-H2O', 'DOSEQLET', '-DOSEQLET', 'DPA-NRES', '-DPA-NRES', 'DPA-SCO', '-DPA-SCO', 'DS+', '-DS+', 'DS-', '-DS-', 'E+&E-', '-E+&E-', 'E+E-GAMM', '-E+E-GAMM', 'ELECTRON', '-ELECTRON', 'EM-ENRGY', '-EM-ENRGY', 'ENERGY', '-ENERGY', 'FISSIONS', '-FISSIONS', 'HAD-CHAR', '-HAD-CHAR', 'HAD-NEUT', '-HAD-NEUT', 'HADGT20M', '-HADGT20M', 'HE-FISS', '-HE-FISS', 'HEAVYION', '-HEAVYION', 'HEHAD-EQ', '-HEHAD-EQ', 'HVY-IONS', '-HVY-IONS', 'ISOTOPE', '-ISOTOPE', 'KAON+', '-KAON+', 'KAON-', '-KAON-', 'KAONLONG', '-KAONLONG', 'KAONS', '-KAONS', 'KAONS+-', '-KAONS+-', 'KAONS0', '-KAONS0', 'KAONSHRT', '-KAONSHRT', 'KAONZERO', '-KAONZERO', 'LAMBDA', '-LAMBDA', 'LAMBDAC+', '-LAMBDAC+', 'LE-FISS', '-LE-FISS', 'LGH-IONS', '-LGH-IONS', 'LOWENNEU', '-LOWENNEU', 'MUON+', '-MUON+', 'MUON-', '-MUON-', 'MUONS', '-MUONS', 'NET-CHRG', '-NET-CHRG', 'NEU-BALA', '-NEU-BALA', 'NEUTRIE', '-NEUTRIE', 'NEUTRIM', '-NEUTRIM', 'NEUTRIT', '-NEUTRIT', 'NEUTRON', '-NEUTRON', 'NIEL-DEP', '-NIEL-DEP', 'NTLOWENE', '-NTLOWENE', 'NUC&PI+-', '-NUC&PI+-', 'NUCLEONS', '-NUCLEONS', 'OMEGA-', '-OMEGA-', 'OMEGAC0', '-OMEGAC0', 'OPTIPHOT', '-OPTIPHOT', 'PHOTON', '-PHOTON', 'PION+', '-PION+', 'PION-', '-PION-', 'PIONS+-', '-PIONS+-', 'PIZERO', '-PIZERO', 'POSITRON', '-POSITRON', 'PROTON', '-PROTON', 'RAY', '-RAY', 'RES-NIEL', '-RES-NIEL', 'RES-NUCL', '-RES-NUCL', 'SI1MEVNE', '-SI1MEVNE', 'SIGMA+', '-SIGMA+', 'SIGMA-', '-SIGMA-', 'SIGMAZER', '-SIGMAZER', 'SQBETA-D', '-SQBETA-D', 'STRANGE', '-STRANGE', 'TAU+', '-TAU+', 'TAU-', '-TAU-', 'THNEU-EQ', '-THNEU-EQ', 'TRITON', '-TRITON', 'UNB-EMEN', '-UNB-EMEN', 'UNB-ENER', '-UNB-ENER', 'WWLOWNEU', '-WWLOWNEU', 'X-MOMENT', '-X-MOMENT', 'XSI-', '-XSI-', 'XSIC+', '-XSIC+', 'XSIC0', '-XSIC0', 'XSIPC+', '-XSIPC+', 'XSIPC0', '-XSIPC0', 'XSIZERO', '-XSIZERO', 'Y-MOMENT', '-Y-MOMENT', 'Z-MOMENT', '-Z-MOMENT', '@LASTPAR']#
- class pymchelper.flair.Input.Vector(x=3, *args)[source]#
Bases:
Vector
flair vector returning a string with {} representation
- class pymchelper.flair.Input.Voxel(filename=None)[source]#
Bases:
object
- Voxel class
- parse the voxel file and create fake cards for the
materials, assignmats and corrfact
that might be embedded in the voxel file