コード例 #1
0
ファイル: StructureMut.java プロジェクト: henniggroup/gasp
  public Organism doVariation(Generation parents, Generation offspring, Selection sel) {
    GAParameters params = GAParameters.getParams();
    Random rand = params.getRandom();

    // pick a parent randomly
    StructureOrg p = (StructureOrg) (sel.doSelection(parents, 1)[0]);
    Cell pStruct = p.getCell();

    // copy the parent's data into new structures
    List<Site> pSites = pStruct.getSites();
    List<Site> newSites = new LinkedList<Site>();

    // perturbing the lattice parameters
    double[][] strain = new double[3][3];
    // initialize the strain matrix to the identity
    // then add some zero mean Gaussian random variables
    for (int i = 0; i < strain.length; i++)
      for (int j = 0; j < strain.length; j++) {
        strain[i][j] = rand.nextGaussian() * sigmaLattice;
        // allow strain matrix perturbations to be only between -1 and 1
        if (strain[i][j] > 1) strain[i][j] = 1;
        if (strain[i][j] < -1) strain[i][j] = -1;
        // add the identity
        if (i == j) strain[i][j] += 1;
      }

    // modify the basis to make newBasis
    double[][] newVectsD = new double[Constants.numDimensions][Constants.numDimensions];
    for (int i = 0; i < Constants.numDimensions; i++)
      for (int j = 0; j < Constants.numDimensions; j++)
        newVectsD[i][j] = pStruct.getLatticeVectors().get(i).getCartesianComponents().get(j);
    // newVects = MatrixMath.SquareMatrixMult(strain, newVects);
    newVectsD = (new Matrix(strain)).times(new Matrix(newVectsD)).getArray();

    List<Vect> newVects = new LinkedList<Vect>();
    for (int i = 0; i < Constants.numDimensions; i++) newVects.add(new Vect(newVectsD[i]));

    // perturb atomic positions
    for (int i = 0; i < pSites.size(); i++) {
      // perturb each site's location with probability mutRate
      List<Double> fracCoords =
          pSites.get(i).getCoords().getComponentsWRTBasis(pStruct.getLatticeVectors());
      if (rand.nextDouble() < mutRate) {
        // perturb by a Gaussian of stddev mutRadius along each axis
        for (int k = 0; k < Constants.numDimensions; k++)
          fracCoords.set(
              k, GAUtils.renormZeroOne(fracCoords.get(k) + rand.nextGaussian() * sigmaAtoms));
      }
      newSites.add(new Site(pSites.get(i).getElement(), new Vect(fracCoords, newVects)));
    }

    // make the new offspring
    StructureOrg result = new StructureOrg(new Cell(newVects, newSites));

    GAOut.out().stdout("StructureMut created new StructureOrg:", GAOut.DEBUG, result.getID());
    GAOut.out().stdout(result.toString(), GAOut.DEBUG, result.getID());

    return result;
  }
コード例 #2
0
ファイル: VaspConfig.java プロジェクト: henniggroup/gasp
 public String getLabel() {
   return cell.getLabel();
 }
コード例 #3
0
ファイル: VaspConfig.java プロジェクト: henniggroup/gasp
 public Composition getComposition() {
   return cell.getComposition();
 }
コード例 #4
0
ファイル: VaspConfig.java プロジェクト: henniggroup/gasp
 public double getEnergyPerAtom() {
   return getTotalEnergy() / cell.getNumSites();
 }