package CrystalObject @ISA = qw() sub RoundSymmetricPosition my ($x) = @_; return 1.0 / 3.0 if($x == 0.3333 or $x == 0.333); return -1.0 / 3.0 if($x == -0.3333 or $x == -0.333); return 2.0 / 3.0 if($x == 0.6667 or $x == 0.667); return -2.0 / 3.0 if($x == -0.6667 or $x == -0.667); return 1.0 / 6.0 if($x == 0.1667 or $x == 0.167); return -1.0 / 6.0 if($x == -0.1667 or $x == -0.167); return 5.0 / 6.0 if($x == 0.8333 or $x == 0.833); return -5.0 / 6.0 if($x == -0.8333 or $x == -0.833); return $x; sub PolarizationFactor my ($Theta, $MonochromaterAlpha) = @_; return 1.0 + $cos2a * $cos2Q * $cos2Q; sub LorentzFactor my ($Theta) = @_; return 1.0 / $cosQ / $sinQ / $sinQ; return $cosQ / $sin2Q / $sin2Q; sub TemperatureFactor my ($Biso, $s) = @_; return exp(-$M); sub SampleName return shift->{SampleName}; sub SetSampleName sub SetSampleName { my ($this,$s)= return $this->{SampleName} = $s; sub SetCrystalName sub SetCrystalName { my ($this,$name) = return $this->{CrystalName} = $name; sub CrystalName sub CrystalName { my ($this) = return $this->{CrystalName}; sub SPGName sub SPGName { my ($this) = return $SPG->SPGName(); sub iSPG sub iSPG { my ($this) = return $SPG->iSPG(); sub iSet sub iSet { my ($this) = return $SPG->iSet(); sub FormulaUnit return shift->{'FormulaUnit'}; sub SetFormulaUnit sub SetFormulaUnit { my($this,$Z)= return $this->{'FormulaUnit'} = $Z; sub ChemicalComposition return shift->{'ChemicalComposition'}; sub SetChemicalComposition sub SetChemicalComposition { my($this,$c)= return $this->{'ChemicalComposition'} = $c; sub SumChemicalComposition return shift->{'SumChemicalComposition'}; sub SetSumChemicalComposition sub SetSumChemicalComposition { my($this,$c)= return $this->{'SumChemicalComposition'} = $c; sub SetnAtomType sub SetnAtomType { my ($this,$n) = return $this->{nAtomType} = $n; sub nAtomType sub nAtomType { my ($this) = return $this->{nAtomType}; sub SetnAsymmetricAtomSite sub SetnAsymmetricAtomSite { my ($this,$n) = return $this->{nAsymmetricAtomSite} = $n; sub nAsymmetricAtomSite sub nAsymmetricAtomSite { my ($this) = return $this->{nAsymmetricAtomSite}; sub SetnTotalExpandedAtomSite sub SetnTotalExpandedAtomSite { my ($this,$n) = return $this->{nTotalExpandedAtomSite} = $n; sub nTotalExpandedAtomSite sub nTotalExpandedAtomSite { my ($this) = return $this->{nTotalExpandedAtomSite}; sub SetCAsymmetricAtomSiteList my ($this, @atomlist) = @_; return $this->{RefAsymmetricAtomSiteList} = \@atomlist; sub GetBravaisLattice sub GetBravaisLattice { my ($this) = return $SPG->GetBravaisLattice(); sub SetCAtomTypeList my ($this, @atomlist) = @_; return $this->{RefAtomTypeList} = \@atomlist; sub LatticeSystem my ($this) = @_; return $this->{LatticeSystem} if($this->{LatticeSystem}); return $SPG->LatticeSystem(); sub SetLatticeSystem my ($this, $latticesystem, $SearchByLatticeParameter, $tollat, $tolangle) = @_; return $ls; sub GetCAtomTypeList my ($this) = @_; return () if($RefAtomList eq ''); return @$RefAtomList; sub GetCAtomType my ($this,$i) = @_; return 0; return $atomtype; sub GetCAsymmetricAtomSiteList my ($this) = @_; return () if($RefAtomList eq ''); return @$RefAtomList; sub Volume my ($this,$UseAtomicUnit) = @_; return $this->{"Volume"} * $k; sub SetSpaceGroup my ($this, $SPGName, $iSPG, $iSet) = @_; return $this->SetCSpaceGroup($SPG); sub SetCSpaceGroup my ($this, $SPG) = @_; return $SPG; sub GetCSpaceGroup my ($this) = @_; return $this->{"SpaceGroup"}; sub GetCAtomSite my ($this,$i) = @_; return 0; return $atomsite; sub GetCExpandedAtomSiteList my ($this) = @_; return () if($RefAtomList eq ''); return @$RefAtomList; sub GetCExpandedAtomSite my ($this,$i) = @_; return 0; return $atomsite; sub Symmetrize my ($this, $tollatt, $tolangle, $tolpos) = @_; sub SymmetrizeParameter my ($this, $ls, $x, $y, $z, $tol) = @_; return ($x, $y, $z); sub RoundParameter my ($this, $x, $tol) = @_; return $tol * int( ($x+0.1*$tol) / $tol ); sub GetCnMultiplicityExpandedAtomSiteList my ($this) = @_; return () if($RefnAtomList eq ''); return @$RefnAtomList; sub new my ($module) = @_; return $this; sub DESTROY my $this = shift; sub PreferentialOrientation my ($this, $IsSheet, $ho, $ko, $lo, $p1, $p2, $h, $k, $l) = @_; return 1.0 if($p1 == 1.0 or $p2 == 0.0); return $p1 + (1.0 - $p1) * exp(-$p2 * $Q * $Q); sub IsVariablePosition my ($this, $x, $y, $z, $pos)= @_; return $VariablePos; sub SetMinimalLatticeParameters my ($this, @a) = @_; return ($a,$b,$c,$alpha,$beta,$gamma); sub SetLatticeParameters my ($this, $a, $b, $c, $alpha, $beta, $gamma) = @_; return if(!defined $a or $a == 0); return ($a, $b, $c, $alpha, $beta, $gamma); sub LatticeParameters my ($this,$UseAtomicUnit) = @_; return ($k*$a, $k*$b, $k*$c, $alpha, $beta, $gamma); sub GetReciprocalDistanceFromK my ($this, $kx0, $ky0, $kz0, $kx1, $ky1, $kz1) = @_; return $d; sub CalculateHKLInterplanarSpacing my ($this, $h, $k, $l) = @_; return 0.0 if($d == 0.0); return $d; sub CalculateDiffractionAngleFromInterplanarSpacing my ($this, $wl, $d) = @_; return 0.0 if($d == 0.0); return 0.0 if(abs($sq) > 1.0); return $Q; sub CalcMetrics my ($this) = @_; return 1; sub LatticeVectors my ($this,$UseAtomicUnit) = @_; sub ReciprocalLatticeVectors my ($this,$UseAtomicUnit) = @_; sub GetPrimitiveCrystal my ($this, $LatticeParameterOnly, $CheckConsistency, $IsPrint) = @_; return $this->ConvertLattice($T, $LatticeParameterOnly, $CheckConsistency, $IsPrint); sub GetMatrixConventionalToPrimitiveCell my ($this) = @_; sub GetMatrixConventionalToPrimitiveReciprocalCell my ($this) = @_; sub GetYRangeForIteration my ($this, $ix) = @_; return $ix; return $ix; return $ix; return 0; return 0; return 0; sub GetZRangeForIteration my ($this, $ix, $iy) = @_; return $iy; return 0; return 0; return 0; return 0; sub ConvertLatticeIndexByLatticeSystem my ($this, $ix, $iy, $iz, $SortDirection) = @_; return (0, $ix, $iy, $iz); return ($IsConverted, sort { return $a <=> $b; return ($IsConverted, sort { return $b <=> $a; return $a <=> $b; return $b <=> $a; return ($IsConverted, @a, $iz); return ($IsConverted, $ix, $iy, $iz); sub Metrics my ($this) = @_; sub GetPerpendicularHKL my ($this, $h1, $k1, $l1, $h2, $k2, $l2) = @_; return @hkl; sub GetVectorFromHKL my ($this, $h, $k, $l) = @_; return @V; sub RMetrics my ($this) = @_; sub SetLatticeVector my ($this, $a11, $a12, $a13, $a21, $a22, $a23, $a31, $a32, $a33) = @_; return; sub CalMetricsFromLatticeVector my ($this) = @_; sub CalculateLatticeConstantFromVector my ($this) = @_; return ($a,$b,$c,$alpha,$beta,$gamma); sub FindNearestEquivalentFractionCoordinate my ($this, $x2, $x) = @_; return $xret; sub FractionalToCartesian my ($this, $x,$y,$z) = @_; return ($xc,$yc,$zc); sub CartesianToFractional my ($this, $xc,$yc,$zc) = @_; sub CalculateVolume my ($this) = @_; return $vol; sub FindAtomTypeByName my ($this, $atomname) = @_; return $type if(uc $name eq uc $atomname); return undef; sub AddAtomType my ($this, $atomname, $CheckRegistered) = @_; return; return $this->{"nAtomType"}; sub GetCBravaisLatticeAsymmetricAtomSiteList my ($this) = @_; return @AtomSite; sub AddAtomSite my ($this, $label, $atomname, $x, $y, $z, $occ, $fx, $fy, $fz) = @_; return $this->{nAsymmetricAtomSite} if($atomname eq ''); return $this->{nAsymmetricAtomSite}; sub GetNearestInterAtomicDistance my ($this, $x0, $y0, $z0, $x1, $y1, $z1) = @_; return $this->GetInterAtomicDistance($x0, $y0, $z0, $x1, $y1, $z1); sub GetInterAtomicDistance my ($this, $x0, $y0, $z0, $x1, $y1, $z1) = @_; return sqrt($r2); sub GetInterAtomicAngle my ($this, $x0, $y0, $z0, $x1, $y1, $z1, $x2, $y2, $z2) = @_; return 0.0 if($dis01 == 0.0); return 0.0 if($dis02 == 0.0); return $angle; sub FindiAtomType my ($this, $atomname) = @_; return $i+1 if($atomname eq uc $name); return -1; sub FindIdenticalAsymmetricSite my ($this, $atomname, $x, $y, $z) = @_; return $ia if($dis < 0.01); return undef; sub ExpandCoordinates my ($this, $DoTranslation) = @_; return; sub AnalyzeChemicalComposition my ($this) = @_; sub CalculateDensity my ($this) = @_; return $this->{Density} if($vol == 0.0); return $this->{"Density"} = Sci::Round($Density / $NA / $vol * 1.0e24, 4); sub SetDensity my ($this, $density) = @_; return $this->{"Density"} = $density; sub Density my ($this) = @_; return $this->{"Density"}; sub ConvertLattice my ($this, $T, $LatticeParameterOnly, $CheckConsistency, $IsPrint) = @_; return $NewCrystal if($LatticeParameterOnly); return $NewCrystal; sub SetMetrics my ($this,$g11,$g12,$g13,$g21,$g22,$g23,$g31,$g32,$g33) = @_; return ($this,$g11,$g12,$g13,$g21,$g22,$g23,$g31,$g32,$g33); sub CalLatticeParametersFromMetrics my ($this) = @_; sub SetIsSelected my($this, $index, $IsSelected) = return $atom->SetIsSelected($IsSelected); return 0; sub IsSelected my($this, $index) = return $atom->IsSelected(); return 0; sub SameIdSiteIndex my ($this, $idm1, $sid) = @_; return $SameIdSiteIndex->{"[$idm1][$sid]"}; sub SortAtomTypeOrder my ($this, $sorttype) = @_; return 1; sub FillAtomTypeData my ($this) = @_; sub AtomicScatteringFactor my ($this, $s) = @_; return $this->asf($s); sub asfElectron my ($this, $iAtomType, $s) = @_; return $val; sub ReadASF my ($this, $Source) = @_; sub asf my ($this, $iAtomType, $s, $Source) = @_; return $b; return $asf; sub Fhkl my ($this, $h, $k, $l, $IsElectron) = @_; return (Re($F), Im($F)); return ($Fr, $Fi); sub OrthorhombicMultiplicity my ($this, $m, $h, $k, $l) = @_; return $m; sub TetragonalMultiplicity my ($this, $m, $h, $k, $l) = @_; return $m; sub HexagonalMultiplicity my ($this, $m, $h, $k, $l) = @_; return 16 if($h != 0 and $k != 0 and $l != 0); return 8 if($h == $k and $l != 0); return 12 if($h == 0 and $k != 0 and $l != 0); return 12 if($h != 0 and $k == 0 and $l != 0); return 12 if($h != 0 and $k != 0 and $l == 0); return 6 if($h == $k and $l == 0); return 6 if($h == 0 and $k != 0 and $l == 0); return 6 if($h != 0 and $k == 0 and $l == 0); return 2 if($h == 0 and $k == 0 and $l != 0); return undef; sub TrigonalMultiplicity my ($this, $m, $h, $k, $l) = @_; return $this->HexagonalMultiplicity($m, $h, $k, $l); sub RhombohedralMultiplicity my ($this, $m, $h, $k, $l) = @_; return $this->HexagonalMultiplicity($m, $h, $k, $l); sub CubicMultiplicity my ($this, $m, $h, $k, $l) = @_; return $m; sub Multiplicity my ($this, $h, $k, $l) = @_; return $this->CubicMultiplicity($m, $h, $k, $l); return $this->TetragonalMultiplicity($m, $h, $k, $l); return $this->TrigonalMultiplicity($m, $h, $k, $l); return $this->HexagonalMultiplicity($m, $h, $k, $l); return $this->OrthorhombicMultiplicity($m, $h, $k, $l); return 2; return undef; sub GetLatticeConversionMatrix my ($this, $PresetRule, $DirectionSelect, $ParametersSelect) = @_; return 1; return ($sT, $T, $tRT, $RT, $tR);