def createTestObjs(self): #Geom/Trajectory self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellB = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords, self.cellB.cartCoords = self.coordsA, self.coordsB trajStepA = trajCoreHelp.TrajStepFlexible(unitCell=self.cellA, step=0, time=10) trajStepB = trajCoreHelp.TrajStepFlexible(unitCell=self.cellB, step=1, time=20) self.traj = trajCoreHelp.TrajectoryInMemory([trajStepA, trajStepB]) #Option object currArgs = [ self.binResObjA, self.oxyIndices, self.hyIndices, self.distFilterIndices, [self.distRangeA, self.distRangeB, self.distRangeC] ] self.optObj = classDistrOptObjs.WaterCountTypesMinDistAndHBondSimpleOpts( *currArgs)
def createTestObjs(self): #Geom/Trajectory self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellB = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords, self.cellB.cartCoords = self.coordsA, self.coordsB trajStepA = trajCoreHelp.TrajStepFlexible(unitCell=self.cellA, step=0, time=self.timeA) trajStepB = trajCoreHelp.TrajStepFlexible(unitCell=self.cellB, step=1, time=self.timeB) self.traj = trajCoreHelp.TrajectoryInMemory([trajStepA, trajStepB]) #Create the classification object options currArgs = [[self.binResObjA], self.oxyIndices, self.hyIndices] currKwargs = {"maxOHDist": self.maxOOHBond, "nNebs": self.nNebs} hydroxylClassifier = classDistrOptObjs.WaterDerivativeBasedOnDistanceClassifierOptsObj( *currArgs, **currKwargs) # currArgs = [ self.oxyIndices, self.hyIndices, hydroxylClassifier, self.distrOptObjs, self.useGroups ] currKwargs = { "useNonHyIdx": self.useNonHyIdx, "useIdxEach": self.useIdxEach } self.filteredOptObj = filteredOptObjHelp.WaterDerivativeFilteredOptsObj_simple( *currArgs, **currKwargs)
def createTestObjs(self): self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellB = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords = self.coordsA self.cellB.cartCoords = self.coordsB extraAttrDictA = { self.velKey: { "value": self.velsA, "cmpType": "numericalArray" } } extraAttrDictB = { self.velKey: { "value": self.velsB, "cmpType": "numericalArray" } } self.trajStepA = trajHelp.TrajStepFlexible( unitCell=self.cellA, extraAttrDict=extraAttrDictA) self.trajStepB = trajHelp.TrajStepFlexible( unitCell=self.cellB, extraAttrDict=extraAttrDictB) self.inpTrajA = trajHelp.TrajectoryInMemory( [self.trajStepA, self.trajStepB])
def _createCells(self): self.cellA = uCellHelp.UnitCell(lattParams=self.lattParamsA, lattAngles=self.lattAnglesA) self.cellB = uCellHelp.UnitCell(lattParams=self.lattParamsA, lattAngles=self.lattAnglesA) self.cellA.cartCoords = self.cartCoordsA self.cellB.cartCoords = self.cartCoordsB
def createTestObjs(self): self.testCellMgTerminated = UCell.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.testCellMgTerminated.fractCoords = self.fractCoordsMgTerminated self.testCellMgTerminatedUpsideDown = UCell.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.testCellMgTerminatedUpsideDown.fractCoords = self.fractCoordsMgTerminatedUpsideDown self.testCellOHTerminated = UCell.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.testCellOHTerminated.fractCoords = self.fractCoordsOHTerminated
def setUp(self): self.cellA = uCellHelp.UnitCell(lattParams=[7,8,9],lattAngles=[90,90,90]) self.cellB = uCellHelp.UnitCell(lattParams=[4,5,6],lattAngles=[90,90,90]) self.coordsA = [ [1,2,3,"Mg"], [4,5,6,"Mg"] ] self.coordsB = [ [2,2,2,"Mg"], [3,3,3,"Mg"], [1,1,1,"Mg"] ] self.stepA, self.stepB = 4, 8 self.timeA, self.timeB = 12, 24 self.tempPath = "temp_file.exyz" self.createTestObjs()
def _createCells(self): self.cellSurf = uCellHelp.UnitCell(lattParams=self.lattParamsSurf, lattAngles=self.lattAnglesSurf) self.cellAbove = uCellHelp.UnitCell(lattParams=self.lattParamsAbove, lattAngles=self.lattAnglesAbove) self.cellBelow = uCellHelp.UnitCell(lattParams=self.lattParamsBelow, lattAngles=self.lattAnglesBelow) self.cellSurf.cartCoords = self.cartCoordsSurf self.cellAbove.cartCoords = self.cartCoordsAbove self.cellBelow.cartCoords = self.cartCoordsBelow
def createTestObjs(self): self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellB = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords, self.cellB.cartCoords = self.coordsA, self.coordsB self.trajStepA = trajHelp.TrajStepBase(unitCell=self.cellA) self.trajStepB = trajHelp.TrajStepBase(unitCell=self.cellB) self.fullTrajA = trajHelp.TrajectoryInMemory( [self.trajStepA, self.trajStepB])
def setUp(self): self.stepA, self.stepB = 0, 50 self.timeA, self.timeB = 0, 500 self.unitCellA = uCellHelp.UnitCell(lattParams=[10, 10, 10], lattAngles=[90, 90, 90]) self.unitCellB = uCellHelp.UnitCell(lattParams=[1, 2, 3], lattAngles=[90, 90, 90]) self.folderPathA = "/fake/path/to/folder" self.fileNameA = "file_name_a" self.folderKeyA = "md_traj_folder" self.fileKeyA = "md_traj_file" self.createTestObjs()
def createTestObjs(self): currKwargs = { "lattParams": self.primLattParamsA, "lattAngles": self.primAnglesA } self.primCellA = uCellHelp.UnitCell(**currKwargs) self.primCellA.fractCoords = self.primFractCoordsA currKwargs = { "lattParams": self.inpCellLattParamsA, "lattAngles": self.inpCellLattAnglesA } self.inpCellA = uCellHelp.UnitCell(**currKwargs) self.inpCellA.fractCoords = self.primFractCoordsA self.testObjA = tCode.CellFillerStandard(self.primCellA)
def createTestObjs(self): currKwargs = { "lattParams": self.primLattParamsA, "lattAngles": self.primAnglesA } self.primCellA = uCellHelp.UnitCell(**currKwargs) self.primCellA.fractCoords = self.primFractCoordsA currKwargs = { "lattParams": self.inpCellLattParamsA, "lattAngles": self.inpCellLattAnglesA } self.inpCellA = uCellHelp.UnitCell(**currKwargs) self.inpCellA.fractCoords = self.primFractCoordsA self.testObjA = tCode.MapPrimToInpCellToMinimiseAverageLatticeParamDeviation( )
def createTestObjs(self): self.singleCellA = uCellHelp.UnitCell(lattParams=self.lattParamsA, lattAngles=self.lattAnglesA) self.singleCellA.cartCoords = self.cartCoordsA self.adsObjsA = [self.adsObjA] self.testObjA = tCode.GetWaterBoxForMDFromEmptyBoxStandard(self.singleCellA, self.adsObjsA,waterAdsGap=self.waterAdsGapA) self.emptyCellA = supCellHelp.superCellFromUCell(self.singleCellA,[2,1,1]) self.emptyCellA.cartCoords = list()
def createTestObjs(self): #Geom self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords = self.coords #Get the test obj currArgs = [ self.oxyIndices, self.hyIndices, self.distFilterIndices, self.distFilterVals ] currKwargs = { "acceptor": self.acceptor, "donor": self.donor, "maxOO": self.maxOO } self.testObj = tCode._DiscHBondCounterBetweenGroupsWithOxyDistFilterPopulator( *currArgs, **currKwargs) self.testObj.nanMatrix = self.nanMatrix #Get an outDict[covers one interface] self.outDict = dict() #Get a sparse matrix calculator self.sparseMatrixCalculator = atomComboCoreHelp._SparseMatrixCalculatorStandard( [self.testObj])
def _loadCellA(): lattParams, lattAngles = [10, 10, 10], [90, 90, 90] cartCoords = [[2, 2, 3, "X"], [3, 3, 3, "X"], [5, 5, 5, "Y"], [5, 5, 7, "Z"]] outCell = uCell.UnitCell(lattParams=lattParams, lattAngles=lattAngles) outCell.cartCoords = cartCoords return outCell
def createTestObjs(self): kwargDict = { "lattParams": self.lattParamsA, "lattAngles": self.lattAnglesA } self.testCellA = uCell.UnitCell(**kwargDict) self.testCellA.cartCoords = self.cartCoordsA
def createTestObjs(self): self.testMapperA = tCode.createMapGeomInfoToDataDictObjFromAtomStyle("full") currArgs = [self.xRangeA, self.yRangeA, self.zRangeA] self.testSimBoxA = tCode.LammpsSimulationBox(*currArgs,self.tiltFactorsA) currKwargs = {"lattParams":self.lattParamsA, "lattAngles":self.lattAnglesA} self.testCellA = uCellHelp.UnitCell(**currKwargs) self.testCellA.cartCoords= self.cartCoordsA
def createTestObjs(self): self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams,lattAngles=self.lattAngles) self.cellA.cartCoords = self.cartCoords currArgs = [self.binResObj, self.oxyIndices, self.hyIndices] currKwargs = {"planeEqn":self.planeEqn, "primaryIdxType":self.primaryIdxType} self.testObj = tCode.WaterPlanarDistOptions(*currArgs, **currKwargs)
def createTestObjs(self): #Create co-ordinates self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords = self.coords #Create a simple one-step trajectory self.stepA = trajCoreHelp.TrajStepFlexible(unitCell=self.cellA) self.trajA = trajCoreHelp.TrajectoryInMemory([self.stepA]) #Create bins then options objects self.distBinsA = binResHelp.BinnedResultsStandard.fromBinEdges(self.distBinEdgesA) self.planarBinsA = binResHelp.BinnedResultsStandard.fromBinEdges(self.planarBinEdgesA) self.distBinsB = binResHelp.BinnedResultsStandard.fromBinEdges(self.distBinEdgesB) self.planarBinsB = binResHelp.BinnedResultsStandard.fromBinEdges(self.planarBinEdgesB) #binResObj, indicesA, indicesB, volume=None, minDistAToB=False): self.minDistsOptsA = calcDistribCoreHelp.CalcRdfOptions(self.distBinsA, self.indicesA_optsA, self.indicesB_optsA, minDistAToB=True) self.minDistsOptsB = calcDistribCoreHelp.CalcRdfOptions(self.distBinsB, self.indicesA_optsB, self.indicesB_optsB, minDistAToB=True) #binResObj, indices, planeEqn=None, volume=None): self.planarDistOptsA = calcRadImpl.CalcPlanarRdfOptions(self.planarBinsA, self.indicesA_optsA) self.planarDistOptsB = calcRadImpl.CalcPlanarRdfOptions(self.planarBinsB, self.indicesA_optsB) self.optsObjs = [ [self.minDistsOptsA, self.planarDistOptsA], [self.minDistsOptsB, self.planarDistOptsB] ]
def createTestObjs(self): self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords = self.coordsA self.inpIndices = [x for x in range(len(self.coordsA))] self.filterFunctA = tCode.FilterToExcludeIndicesWithoutNebsAmongstRemaning( self.maxDist, restrictToPairs=self.restrictToPairs)
def createTestObjs(self): self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords = self.coordsA self.inpIndices = [x for x in range(len(self.coordsA))] self.filterFunctA = tCode.FilterToExcludeIndicesFurtherOutOfPlaneThanCutoff( self.maxDist, self.planeEqn, self.inpPointsA)
def _loadTestCellA(): lattParams, lattAngles = [10, 10, 10], [90, 90, 90] cartCoords = [[4, 4, 4, "X"], [6, 6, 4, "X"], [7, 6, 4, "X"], [8, 8, 6, "Y"]] outCell = uCellHelp.UnitCell(lattParams=lattParams, lattAngles=lattAngles) outCell.cartCoords = cartCoords return outCell
def createTestObjs(self): self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords = self.cartCoords self.trajStepA = trajCoreHelp.TrajStepFlexible(unitCell=self.cellA) #Create the bin objs self.binObjA = binResHelp.BinnedResultsStandard.fromBinEdges( self.binEdgesA) self.binObjB = binResHelp.BinnedResultsStandard.fromBinEdges( self.binEdgesB) #Create single binners self.binnerA = tCode._WaterRotationAngleBinnerFixedIndices( resBins=self.binObjA, indices=self.indicesA, angleIdx=self.angleIdxA) self.binnerB = tCode._WaterRotationAngleBinnerFixedIndices( resBins=self.binObjB, indices=self.indicesB, angleIdx=self.angleIdxB) #Create the multi binner (the test obj) self.testObj = tCode._WaterRotationAngleMultiBinnerFixedIndices( [self.binnerA, self.binnerB])
def createTestObjs(self): #Define some rotated water molecules #setting up water with an angle of 90 degrees and sqrt(2) bondlengths makes this simpler waterAzi90_pitch20 = [[0, 0, 0, "O"], [-1, 0.94, 0.34, "H"], [1, 0.94, 0.34, "H"]] #bin [1][1] waterAzi0_pitch20 = [[0, 0, 0, "O"], [0.94, 1.0, 0.34, "H"], [0.94, -1, 0.34, "H"]] #bin [0][1] waterAzi0_pitchm20 = [[0, 0, 0, "O"], [0.94, 1.0, -0.34, "H"], [0.94, -1, -0.34, "H"]] #bin [0][0] #Sort the trajectory; default is to use a one step trajectory self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords = waterAzi90_pitch20 + waterAzi0_pitch20 + waterAzi0_pitchm20 + waterAzi0_pitchm20 self.stepA = trajCoreHelp.TrajStepFlexible(unitCell=self.cellA) self.trajA = trajCoreHelp.TrajectoryInMemory([self.stepA]) #Create the options objects self.aziBins = binResHelp.BinnedResultsStandard.fromBinEdges( self.aziEdges) self.pitchBins = binResHelp.BinnedResultsStandard.fromBinEdges( self.pitchEdges) self.aziOpts = waterRotHelp.CalcStandardWaterOrientationDistribOptions( self.aziBins, self.waterIndicesAll, angleType="azimuth") self.pitchOpts = waterRotHelp.CalcStandardWaterOrientationDistribOptions( self.pitchBins, self.waterIndicesAll, angleType="pitch")
def getNearestImageNebCoordsMatrixBasic(inpCell, indicesA=None, indicesB=None): """ Gets a matrix where each element contains [coordA,coordB] where A,B are row/column indices. coordA is the same co-ordinate found in inpCell; coordB is the nearest neighbour for it Args: inpCell: (plato_pylib UnitCell object) indicesA: (Optional, iter of ints) Indices of the atoms to include for the first dimension; Default is to include ALL atoms indicesB: (Optional, iter of ints) Indices of the atoms to include for the second dimension; Default is indicesA Returns outMatrix: (NxM matrix) outMatrix[n][m] = [coordN, coordM] where N and M are lengths of indicesA and indicesB """ #Sort out default args fractCoords = inpCell.fractCoords fCoordsNoEles = np.array([x[:3] for x in fractCoords]) eleList = [x[-1] for x in fractCoords] indicesA = [x for x in range(len(fractCoords)) ] if indicesA is None else indicesA indicesB = indicesA if indicesB is None else indicesB #Figure out the value for each row; we need useCell to exploit some relevant function in the ucell_class thing useCell = uCellHelp.UnitCell(lattParams=inpCell.getLattParamsList(), lattAngles=inpCell.getLattAnglesList()) outMatrix = list() for idxA in indicesA: currRow = _getSingleRowOfNearestImageNebCoordsMatrix( fCoordsNoEles, eleList, useCell, idxA, indicesB) outMatrix.append(currRow) return outMatrix
def createTestObjs(self): #Sort the cell self.cellA = uCellHelp.UnitCell(lattParams=[10, 10, 10], lattAngles=[90, 90, 90]) self.cellA.cartCoords = self.cartCoords # self.binResObjs = [self.binResObjA, self.binResObjB] currArgs = [ self.binResObjs, self.oxyIndices, self.hyIndices, self.distFilterIndices, self.distFilterRanges ] currKwargs = { "nDonorFilterRanges": self.nDonorFilterRanges, "nAcceptorFilterRanges": self.nAcceptorFilterRanges, "nTotalFilterRanges": self.nTotalFilterRanges, "maxOOHBond": self.maxOOHBond, "maxAngleHBond": self.maxAngleHBond, "checkInputConsistent": self.checkInputConsistent, "adsSiteMinHozToOtherAdsSiteRanges": self.adsSiteMinHozToOtherAdsSiteRanges } self.testObj = tCode.WaterAdsorbedClassifier_usingMinHozDistsBetweenAdsorptionSitesOptsObj( *currArgs, **currKwargs)
def setUp(self): self.unitCellA = uCellHelp.UnitCell(lattParams=[10, 10, 10], lattAngles=[90, 90, 90]) self.timeA, self.timeB = 2, 3 self.stepA, self.stepB = 0, 50 self.fileNameA = "temp_file_a.traj" self.createTestObjs()
def getSingleLayerRocksalt011FromPrimitiveCell(primCell): """ Args: primCell: (plato_pylib UnitCell object) This must be a primitive rock salt cell. Meaning 2 atoms, with each lattice angle=60 degrees and a=b=c Returns outCell: (plato_pylib UnitCell object) Contains a 4-atom unit-cell which forms the basis for forming rock-salt 011 surfaces (it is one layer) Raises: AssertionError: If the input primitive cell is not a rock salt cell. Probably not garanteed to be raised if an incompatible cell is passed, but at least catches some errors. """ assert _uCellIsRockSaltPrimitive( primCell, printError=True ), "UnitCell {} is not a primitive rock salt cell".format(primCell) atomA, atomB = primCell.fractCoords[0][-1], primCell.fractCoords[1][-1] conventLattParam = (2 * primCell.lattParams["a"]) / math.sqrt(2) otherLattParams = primCell.lattParams["a"] outputLattParams = [conventLattParam, otherLattParams, otherLattParams] outputLattAngles = [90, 90, 90] fractCoords = [[0.0, 0.0, 0.0, atomA], [0.0, 0.5, 0.5, atomB], [0.5, 0.0, 0.0, atomB], [0.5, 0.5, 0.5, atomA]] outCell = uCell.UnitCell(lattParams=outputLattParams, lattAngles=outputLattAngles) outCell.fractCoords = fractCoords return outCell
def createTestObjs(self): #Define some rotated water molecules #setting up water with an angle of 90 degrees and sqrt(2) bondlengths makes this simpler waterAzi90_pitch20 = [ [0, 0, 0 + 7, "O"], [-1, 0.94, 0.34 + 7, "H"], [1, 0.94, 0.34 + 7, "H"] ] #Translated by +7 for planar dists stuff [means dist=3] waterAzi0_pitch20 = [[0, 0, 0 + 1, "O"], [0.94, 1.0, 0.34 + 1, "H"], [0.94, -1, 0.34 + 1, "H"]] waterAzi0_pitchm20 = [[0, 0, 0, "O"], [0.94, 1.0, -0.34, "H"], [0.94, -1, -0.34, "H"]] #Sort the trajectory; default is to use a one step trajectory self.cellA = uCellHelp.UnitCell(lattParams=self.lattParams, lattAngles=self.lattAngles) self.cellA.cartCoords = waterAzi90_pitch20 + waterAzi0_pitch20 + waterAzi0_pitchm20 + waterAzi0_pitchm20 self.stepA = trajCoreHelp.TrajStepFlexible(unitCell=self.cellA) self.trajA = trajCoreHelp.TrajectoryInMemory([self.stepA]) #Create the options objects self.aziBinsA = binResHelp.BinnedResultsStandard.fromBinEdges( self.aziEdgesA) self.pitchBinsA = binResHelp.BinnedResultsStandard.fromBinEdges( self.pitchEdgesA) self.planarBinsA = binResHelp.BinnedResultsStandard.fromBinEdges( self.planarEdgesA) self.oxyDistBinsA = binResHelp.BinnedResultsStandard.fromBinEdges( self.oxyDistEdgesA) self.aziBinsB = binResHelp.BinnedResultsStandard.fromBinEdges( self.aziEdgesB) self.pitchBinsB = binResHelp.BinnedResultsStandard.fromBinEdges( self.pitchEdgesB) self.planarBinsB = binResHelp.BinnedResultsStandard.fromBinEdges( self.planarEdgesB) self.oxyDistBinsB = binResHelp.BinnedResultsStandard.fromBinEdges( self.oxyDistEdgesB) #Create options objs self.aziOptsA = waterRotHelp.CalcStandardWaterOrientationDistribOptions( self.aziBinsA, self.waterIndicesA, angleType="azimuth") self.pitchOptsA = waterRotHelp.CalcStandardWaterOrientationDistribOptions( self.pitchBinsA, self.waterIndicesA, angleType="pitch") self.planarOptsA = tCode.CalcWaterPlanarDistribOptions_fromOxy( self.planarBinsA, self.waterIndicesA) self.oxyDistOptsA = tCode.CalcWaterOxyMinimumDistOptions( self.oxyDistBinsA, self.waterIndicesA, self.oxyDistIndices) self.aziOptsB = waterRotHelp.CalcStandardWaterOrientationDistribOptions( self.aziBinsB, self.waterIndicesB, angleType="azimuth") self.pitchOptsB = waterRotHelp.CalcStandardWaterOrientationDistribOptions( self.pitchBinsB, self.waterIndicesB, angleType="pitch") self.planarOptsB = tCode.CalcWaterPlanarDistribOptions_fromOxy( self.planarBinsB, self.waterIndicesB) self.oxyDistOptsB = tCode.CalcWaterOxyMinimumDistOptions( self.oxyDistBinsB, self.waterIndicesB, self.oxyDistIndices) self.optsObjs = [[self.aziOptsA, self.pitchOptsA], [self.aziOptsB, self.pitchOptsB]]
def testToDictAndFromDictConsistent(self): self.unitCell = uCellHelp.UnitCell(lattParams=[1, 2, 3], lattAngles=[90, 90, 90]) self.createTestObjs() expObj = self.testObjA outDict = self.testObjA.toDict() actObj = tCode.TrajStepBase.fromDict(outDict) self.assertEqual(expObj, actObj)
def _createCubicSurfaceGeom(self): kwargs = { "lattParams": [self.cellLengthA for x in range(3)], "lattAngles": [90 for x in range(3)] } outCell = uCellHelp.UnitCell(**kwargs) outCell.cartCoords = self.surfCartCoordsWithSymbols return outCell