Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: key error #21

Closed
RuiFilipeCampos opened this issue Aug 1, 2021 · 5 comments · Fixed by #26
Closed

BUG: key error #21

RuiFilipeCampos opened this issue Aug 1, 2021 · 5 comments · Fixed by #26

Comments

@RuiFilipeCampos
Copy link
Owner

seeding with: 0, 0, 0, 123
seeding with: 0, 0, 0, 89715
Traceback (most recent call last):
D:\a\MontyCarlo\MontyCarlo\tests\_cmd.py
  File "D:\a\MontyCarlo\MontyCarlo\MontyCarlo\materials\database.py", line 553, in __getitem__
['import_test.py', '--built_inplace']
The path 'D:\a\MontyCarlo\MontyCarlo' has been appended to `sys.path`. If the path looks weird, you probably ran the script as a python file. Please run it as a module:
`python -m unit_test --built_inplace`
Importing MontyCarlo
Importing .settings
_________________________________________________________________
INSTALL PATH:  D:\a\MontyCarlo\MontyCarlo\MontyCarlo
----
DEBUG: False
---------------
PHOTON CUT OFF: 5110.0 MeV
----
ELECTRON CUT OFF: 100000.0 MeV
---------------------------------------------


BRANCH: pre-alpha/0.0.41

____INIT_____
Importing `.plotter`
Importing .tools.interpol1
Importing .tools.CubicInverseTransform ...
Importing `.materials.pyRelax`
Importing .materials.database
Importing .tools.vectors
Importing .tools.RITA
>>>> IMPORTING material.photon.CrossSection.pyx
>>>> IMPORTING material.photon.pyx
Importing `.materials.materials`
Importing `.materials.logger`
>>>> IMPORTING main.pyx
Importing .materials.electron.main
Importing `.types`
Importing .particles.particle
Importing .geometry.main
Importing .geometry.CSG
Importing .particles.positrons
Importing particles.photons
Importing .particles.electrons
Size of mater 128
Importing .sources
SEED: 725832839
Creating a material
Compiling data for material 'Untitled'
0
NUMBER OF PROFILES 1
1 1
0
1
2
NUMBER OF PROFILES 3
8 4
        DATA PROCESSING IN PYTHON
        > a = 2.9395944556963114
                err =  0.0 %
    2x<Atom Z=1, Aw = 1.00797 amu, I = 19.2 eV> 
    <Shell #1, fk = 1.0, Uk = 13.6 eV, Wk = 40.360955827712104 eV> 
 
    1x<Atom Z=8, Aw = 15.9994 amu, I = 95.0 eV> 
    <Shell #1, fk = 2.0, Uk = 538.0 eV, Wk = 1581.521246377744 eV> 
    <Shell #3, fk = 3.33, Uk = 21.049999999999997 eV, Wk = 62.8342736655728 eV> 
 

        GENERATING GOS MODEL IN CYTHON
        > creating shells
        > making density corrections
        > note: KE = logspace(1, 9, 5_000)
        GENERATING FULL SP
    return self.__cache__[Z+1]
KeyError: 8.0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\MontyCarlo\MontyCarlo\tests\import_test.py", line 14, in <module>
    myco.Mat({1:2, 8:1}, 1)
  File "MontyCarlo\materials\materials.pyx", line 894, in MontyCarlo.materials.materials.Mat
  File "MontyCarlo\materials\materials.pyx", line 990, in MontyCarlo.materials.materials.Material.__init__
  File "MontyCarlo\materials\electron\main.pyx", line 295, in MontyCarlo.materials.electron.main.Electron.__init__
  File "MontyCarlo\materials\electron\main.pyx", line 614, in MontyCarlo.materials.electron.main.Inelastic.__init__
  File "MontyCarlo\materials\electron\GOSfinal.pyx", line 127, in MontyCarlo.materials.electron.GOSfinal.gosMolecule.__init__
  File "MontyCarlo\materials\electron\GOSfinal.pyx", line 368, in MontyCarlo.materials.electron.GOSfinal.gosAtom.__init__
  File "MontyCarlo\materials\electron\GOSfinal.pyx", line 1088, in MontyCarlo.materials.electron.GOSfinal.gosInnerShell.__init__
  File "D:\a\MontyCarlo\MontyCarlo\MontyCarlo\materials\database.py", line 555, in __getitem__
    self.__cache__[Z+1] = getEEDL(Z+1)
  File "D:\a\MontyCarlo\MontyCarlo\MontyCarlo\materials\database.py", line 294, in getEEDL
    EEDL_dict = get_bookmarked_text(EEDL_path)
NameError: name 'EEDL_path' is not defined
Error: Process completed with exit code 1.
@RuiFilipeCampos
Copy link
Owner Author

@RuiFilipeCampos
Copy link
Owner Author

print(" GENERATING FULL SP")
# these values are not supposed to change after renormalization
# I'll be collecting data here, and use that to renormalize
FULL = [np.array(self.get(E, True)) for E in eax]
FULL = np.array(FULL)
self.gosMOLECULE = GOSfinal.gosMolecule(self.GOSmodel, formula)
# interp = np.array(self.gosMOLECULE.totalCS)
# interp = interp*formula.N
# self.imfpA = interp[0]
# self.imfpB = interp[1]
print(" CUTTING SHELLS FROM MODEL")

@RuiFilipeCampos
Copy link
Owner Author

self.gosMOLECULE = GOSfinal.gosMolecule(self.GOSmodel, formula)

@RuiFilipeCampos
Copy link
Owner Author

cdef class gosMolecule:
def __reduce__(self):
this = MAP()
this.Nat = self.Nat
import numpy as np
this.totalCS = np.array(self.totalCS)
this.number_density = self.number_density
this.gosATOMS = np.array(self.gosATOMS)
return rebuildgosMolecule, (this, )
def __init__(gosMolecule self, CMolecule cmolecule, formula):
self.Nat = cmolecule.N + 1 #to include CB shell
self.totalCS = makeLinLin(eax, cmolecule.SIGMA0)
gosATOMS = []
cdef CAtom catom
self.number_density = formula.N
#cb shell first, most likely one
#catom = cmolecule.cb #cb inherits from CAtom
gosATOMS.append(gosCBShell(cmolecule.cb, cmolecule.SIGMA0cb))
for catom in cmolecule.ATOMS:
gosATOMS.append(gosAtom(catom, formula))
self.gosATOMS = np.array(gosATOMS)
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.initializedcheck(False)
@cython.cdivision(True)
cdef void sample(gosMolecule self, mixmax_engine* genPTR, int index, double E, PARTICLES *particles):
cdef double r = genPTR.get_next_float()*(self.totalCS[0, index] + E*self.totalCS[1, index])
cdef gosAtom atom
cdef int i = 0
cdef double cumul = 0
for i in range(self.Nat):
atom = self.gosATOMS[i]
cumul += atom.totalCS[0, index] + E*atom.totalCS[1, index]
if r < cumul:
atom.sample(genPTR, index, E, particles)
break
def cut(self, double Wcc, shells_for_softIMFP):
"""
"""
newATOMS = []
currentATOMS = np.array(self.gosATOMS)
cdef gosAtom atom
atom = self.gosATOMS[0]
if (<gosCBShell> atom).Wk > Wcc:
return False
shells_for_softIMFP.append([(<gosCBShell> atom).fk, (<gosCBShell> atom).Wk])
cdef int i = 0
for atom in currentATOMS[1:]:
empty = atom.cut(Wcc, shells_for_softIMFP)
if not empty:
i += 1
newATOMS.append(atom)
if i == 0:
self.totalCS = np.array(self.totalCS)*0
return True
self.Nat = len(newATOMS)
self.gosATOMS = np.array(newATOMS)
new_totalCS = np.array(self.totalCS)*0
for atom in self.gosATOMS:
new_totalCS += np.array(atom.totalCS)
self.totalCS = np.array(new_totalCS) #- np.array(atom.totalCS)
return False
def makearray(self):
#cdef double [:, ::1]
cdef double a, b, Uk, Wk
arr = [list() for _ in range((len(eax)-1))]
arr_atoms = list()
cdef gosAtom atom
cdef gosShell shell
# ionizationCS[identify which shell, A OR B, ENERGY_index]
cdef int lenposs = 0
cdef int atom_index, shell_index
for atom_index in range(self.Nat):
print("molec.Nat", self.Nat)
atom = self.gosATOMS[atom_index]
arr_atoms.append(atom.ATOMptr)
for shell_index in range(atom.Nsh):
print("atom.Nsh", atom.Nsh)
shell = atom.gosSHELLS[shell_index]
Wk = shell.Wk
if shell.Nsh == 0:
for i in range(len(eax) - 1):
CS = np.array(shell.totalCS)
CS_E = CS[:, i]
a = CS_E[0]*self.number_density
b = CS_E[1]*self.number_density
p1, p2, p3 = shell.p1, shell.p2, shell.p3
arr[i] += [a*p1[i], b*p1[i], Wk, 0, 0., 0.]
arr[i] += [a*p2[i], b*p2[i], Wk, 0, 0., 0.]
arr[i] += [a*p3[i], b*p3[i], Wk, 0, 0., 0.]
continue
for j in range(shell.Nsh):
print("shell.Nsh", shell.Nsh)
CS = np.array(shell.ionizationCS[j])
Uk = shell.BE[j]
lenposs += 6*3
p1, p2, p3 = shell.p1, shell.p2, shell.p3
print(Uk)
for i in range(len(eax) - 1):
CS_E = CS[:, i]
a = CS_E[0]*self.number_density
b = CS_E[1]*self.number_density
arr[i] += [a*p1[i], b*p1[i], Wk, Uk, <double> atom_index, <double> shell.INDEX[j]]
arr[i] += [a*p2[i], b*p2[i], Wk, Uk, <double> atom_index, <double> shell.INDEX[j]]
arr[i] += [a*p3[i], b*p3[i], Wk, Uk, <double> atom_index, <double> shell.INDEX[j]]
# for j in range(shell.Nsh):
# a = shell.ionizationCS[j, 0, i]
# b = shell.ionizationCS[j, 1, i]
# Uk = shell.BE[j]
# arr[i] += [a, b, Wk, Uk]
arr = np.array(arr, order = "C")
arr_atoms = np.array(arr_atoms, order = "C")
return arr, len(arr), arr_atoms
def __getitem__(self, Z):
cdef gosAtom atom
for atom in self.gosATOMS:
if atom.Z == Z:
return atom
def plot( self, units = "cm2"):
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
totalCS = np.array(self.totalCS)
if units == "cm2":
plt.plot(eax[:-1], totalCS[0] + totalCS[1]*eax[:-1])
plt.ylabel("MOLECULE (cm^2) ")
elif units == "barn":
plt.plot(eax[:-1], (totalCS[0] + totalCS[1]*eax[:-1])*1e24)
plt.ylabel("MOLECULE (barn) ")
plt.xlabel("Energy of Incident Electron (eV)")
plt.xscale("log"); plt.yscale("log");
plt.grid(which = "both")
plt.show()

@RuiFilipeCampos
Copy link
Owner Author

def getEEDL(Z):
"""
DATABASE DOCS:
https://drive.google.com/file/d/1ef8Ww_0PPWuLEuwpfv9KOF4wyd75_eOp/
"""
Z = int(Z)
file = str(Z) + ".txt"
EPDL_path = str(__materials__/'EEDL'/file)
del file
#EEDL_path = directory + r"\\EEDL\\" + str(Z) + ".txt"
EEDL_dict = get_bookmarked_text(EEDL_path)
for Id in EEDL_dict:
EEDL_dict[Id] = EEDLtable(EEDL_dict[Id], Id, Z)
return EEDL_dict

This was linked to pull requests Aug 1, 2021
RuiFilipeCampos added a commit that referenced this issue Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant