Giter Club home page Giter Club logo

Comments (5)

RuiFilipeCampos avatar RuiFilipeCampos commented on August 30, 2024

https://github.com/RuiFilipeCampos/MontyCarlo/tree/fix/%2321

from montycarlo.

RuiFilipeCampos avatar RuiFilipeCampos commented on August 30, 2024

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")

from montycarlo.

RuiFilipeCampos avatar RuiFilipeCampos commented on August 30, 2024

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

from montycarlo.

RuiFilipeCampos avatar RuiFilipeCampos commented on August 30, 2024

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()

from montycarlo.

RuiFilipeCampos avatar RuiFilipeCampos commented on August 30, 2024

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

from montycarlo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.