def ligandDistances(ciffile): cif = cef.CifFile(ciffile) for asuc in cif.asymunitcell: if asuc[1].strip('3+') in ['Sm','Pm','Nd','Ce','Dy','Ho','Tm','Pr','Er','Tb','Yb']: onesite = asuc break ## Check for multiply defined atoms differentPositionsA = [] differentPositionsB = [] for ii, at in enumerate(cif.unitcell): if at[4] < 0: print('negative atom!',ii, at) if at[0][-1] in ["'", "B", "b"]: differentPositionsA.append(at[0]) differentPositionsB.append(at[0].replace("'","").replace("B","A").replace("b","a")) if len(differentPositionsA) > 0: cif_a = deepcopy(cif) cif_b = deepcopy(cif) unitcellA = [] unitcellB = [] for ii, at in enumerate(cif.unitcell): if at[0] in differentPositionsA: unitcellA.append(at) elif at[0] in differentPositionsB: unitcellB.append(at) else: unitcellA.append(at) unitcellB.append(at) cif_a.unitcell = unitcellA cif_b.unitcell = unitcellB cifs = [cif, cif_a, cif_b] else: cifs = [cif] unitcellshifts = np.array([[0,0,0], [1,0,0], [0,1,0], [0,0,1], [-1,0,0],[0,-1,0],[0,0,-1], [1,1,0], [0,1,1], [1,0,1], [-1,1,0],[0,-1,1],[1,0,-1], [1,-1,0],[0,1,-1],[-1,0,1], [-1,-1,0],[0,-1,-1],[-1,0,-1], [1,1,1], [1,1,-1], [1,-1,1], [-1,1,1], [-1,-1,-1], [-1,-1,1], [-1,1,-1],[1,-1,-1]]) #neighborlist = [] distlist = [] for ii, at in enumerate(cifs[0].unitcell): if at[4] < 0: print('negative atom!',ii, at) #if ion not in at[0]: for ucs in unitcellshifts: distVec0 = cifs[0].latt.cartesian(np.array(onesite[2:5]) - (np.array(at[2:5]) + ucs)) #neighborlist.append([at[1], np.linalg.norm(distVec0), distVec0]) distlist.append(np.linalg.norm(distVec0)) return np.sort(distlist)
import numpy as np import matplotlib.pyplot as plt import PyCrystalField as cef ########### Import CIF file YTOLig, Yb = cef.importCIF('yto.cif','Yb1') Yb.diagonalize() ########### print eigenvectors Yb.printEigenvectors() ########### plot neutron spectrum hw = np.linspace(0,100,200) intens = Yb.neutronSpectrum(hw, Temp=20, Ei=120, ResFunc= lambda x: 4, gamma = 1) plt.figure() plt.plot(hw, intens) plt.show()
import sys from pythonlib.functions import SimDat ions = [ 'Sm3+', 'Pm3+', 'Nd3+', 'Ce3+', 'Dy3+', 'Ho3+', 'Tm3+', 'Pr3+', 'Er3+', 'Tb3+', 'Yb3+' ] for ion in ions: print('*' * 40, ion) filename = ion[:2] + 'TO' Data = SimDat('SimulatedData/{}_simdat.txt'.format(filename)) YTOLig, Yb = cef.importCIF('SimulatedDataCode/{}.cif'.format(filename), ion[:2] + '1') Yb.diagonalize() maxE = np.max(Yb.eigenvalues) * 1.1 + 5 RF = lambda x: 0.03 * (maxE - x / 1.3) ############# npts = len(Data.hw) * len(Data.Temps) def err_global(CFLevelsObject, coeff, gammas, pref): """Global error to all functions passed to it, used for fitting""" # define new Hamiltonian newH = np.sum([a * b for a, b in zip(CFLevelsObject.O, coeff)], axis=0) CFLevelsObject.diagonalize(newH) erro = 0
import numpy as np import matplotlib.pyplot as plt import PyCrystalField as cef ########### Import CIF file # We can specify the Z axis of the point charge model if we choose. # PyCrystalField will then find a y axis orthogonal to it with a # mirror plane (if one exists) # You can also specify the y axis if you want with "Yaxis = [ , , ]" YTOLig, Yb = cef.importCIF('yto.cif', 'Yb1', Zaxis=[1, 1, 0]) ########### print eigenvectors Yb.printEigenvectors() ########### plot neutron spectrum hw = np.linspace(0, 100, 200) intens = Yb.neutronSpectrum(hw, Temp=20, Ei=120, ResFunc=lambda x: 4, gamma=1) plt.figure() plt.plot(hw, intens) plt.show()
cifname = cf.split('/')[1] #YTOLig, Yb = cef.importCIF(cf, NumIonNeighbors=3) sample_ID = cifIDs[i] name = str(sample_ID) try: coordnum = int(SD.data['coordination_number'][sample_ID]) if 'Carbon' in SD.data['coordination_elements'][sample_ID]: raise ValueError elif 'carbon' in SD.data['coordination_elements'][sample_ID]: raise ValueError except ValueError: coordnum = None print('CoordinationNumber:', coordnum) PCFoutput = cef.importCIF(cf, NumIonNeighbors=1, CoordinationNumber=coordnum) ### See how many neighbors. If there's less than seven, redo. if coordnum == None: nin = 1 while True: try: YTOLig, Yb = PCFoutput except ValueError: YTOLig = PCFoutput[0][0] if len(YTOLig.bonds) < 7: nin += 1 PCFoutput = cef.importCIF(cf, NumIonNeighbors=nin, CoordinationNumber=coordnum) elif len(YTOLig.bonds) >= 20:
import numpy as np import PyCrystalField as cef ########### Import CIF file NCNFLig, Ni = cef.importCIF('NaCaNi2F7.cif', 'Ni1', ionS=1, ionL=3) ########### print eigenvectors Ni.printEigenvectors()
'Sm3+', 'Pm3+', 'Nd3+', 'Ce3+', 'Dy3+', 'Ho3+', 'Tm3+', 'Pr3+', 'Er3+', 'Tb3+', 'Yb3+' ] for ion in ions: filename = ion[:2] + 'TO' ####### Create copies of cif files with open('kes.cif') as f1: with open(filename + '.cif', 'w') as f2: for line in f1.readlines(): f2.write( line.replace('Er3+', ion).replace('Er1', ion[:2] + '1')) ########### Import CIF file YTOLig, Yb = cef.importCIF(filename + '.cif', ion[:2] + '1') ########### print eigenvectors Yb.printEigenvectors() maxE = np.max(Yb.eigenvalues) * 1.1 + 5 ########### plot neutron spectrum RF = lambda x: 0.03 * (maxE - x / 1.3) hw = np.linspace(5, maxE, 200) Temps = [10, 200] intens1 = Yb.normalizedNeutronSpectrum(hw, Temp=10, ResFunc=RF, gamma=0.5 * maxE / 100)