""" catima python module ~~~~~~~~~~~ This module provides interface to the catima c++ library :copyright: (c) 2017 by Andrej Prochazka :licence: GNU Affero General Public License, see LICENCE for more details """ cimport catimac from enum import IntEnum import numpy cdef class Material: cdef catimac.Material cbase def __cinit__(self, elements=None, thickness=None, density=None, i_potential=None): self.cbase = catimac.Material() if(elements and (isinstance(elements[0],float) or isinstance(elements[0],int))): self.cbase.add_element(elements[0],elements[1],elements[2]) if(elements and isinstance(elements[0],list)): for e in elements: self.cbase.add_element(e[0],e[1],e[2]) self.cbase.calculate() if(not thickness is None): self.thickness(thickness) if(not density is None): self.density(density) if(not i_potential is None): self.I(i_potential) cdef from_c(self, catimac.Material &other): self.cbase = other cdef catimac.Material getc(self): cdef catimac.Material res res = self.cbase return res def copy(self): res = Material() res.cbase = self.cbase return res def add_element(self, a, z , s): self.cbase.add_element(a, z, s) def ncomponents(self): return self.cbase.ncomponents() def molar_mass(self): return self.cbase.M() def M(self): return self.cbase.M() def density(self, val=None): if(val is None): return self.cbase.density() else: return self.cbase.density(val) def thickness(self, val=None): if(val is None): return self.cbase.thickness() else: return self.cbase.thickness(val) def I(self, val=None): if(val is None): return self.cbase.I() else: return self.cbase.I(val) class material(IntEnum): PLASTIC = 201 AIR = 202 CH2 = 203 LH2 = 204 LD2 = 205 WATER = 206 DIAMOND = 207 GLASS = 208 ALMG3 = 209 ARCO2_30 = 210 CF4 = 211 ISOBUTANE = 212 KAPTON = 213 MYLAR = 214 NAF = 215 P10 = 216 POLYOLEFIN = 217 CMO2 = 218 SUPRASIL = 219 HAVAR = 220 STEEL = 221 METHANE = 222 def get_material(int matid): res = Material() cdef catimac.Material cres = catimac.get_material(matid); res.from_c(cres) return res cdef class Target: cdef catimac.Target cbase def __cinit__(self,a,z,stn): self.cbase.A = a self.cbase.Z = z self.cbase.stn = stn def A(self): return self.cbase.A def Z(self): return self.cbase.Z def stn(self): return self.cbase.stn cdef class Layers: cdef public: materials def __init__(self): self.materials=[] def add(self,Material m): self.materials.append(m.copy()) def num(self): return len(self.materials) def get(self, key): return self.materials[key] def __getitem__(self, key): if(isinstance(key,int) and key0 and data.p.Z>0 and data.m.ncomponents()>0): matter = [] for j in range(data.m.ncomponents()): e = data.m.get_element(j) matter.append([e.A,e.Z,e.stn]) res.append({"projectile":[data.p.A,data.p.Z],"matter":matter, "config":data.config}) return res def catima_info(): print("CATIMA version = 1.1") print("number of energy points = %g"%max_datapoints) print("min energy point = 10^%g MeV/u"%logEmin) print("max energy point = 10^%g MeV/u"%logEmax)