From: <pie...@us...> - 2013-08-09 11:25:02
|
Revision: 18533 http://sourceforge.net/p/jmol/code/18533 Author: pierocanepa Date: 2013-08-09 11:24:58 +0000 (Fri, 09 Aug 2013) Log Message: ----------- I'm starting developing a redear for Abinit Added Paths: ----------- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java Added: trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java (rev 0) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java 2013-08-09 11:24:58 UTC (rev 18533) @@ -0,0 +1,74 @@ +package org.jmol.adapter.readers.xtal; + + +/** + * http://cms.mpi.univie.ac.at/vasp/ + * + * @author Pieremanuele Canepa, MIT, + * Department of Material Sciences and Engineering + * + * + * @version 1.0 + */ + +import org.jmol.adapter.smarter.AtomSetCollectionReader; +import org.jmol.util.TextFormat; + +public class AbinitReader extends AtomSetCollectionReader { + + private float[] cellLattice; + + + @Override + protected void initializeReader() { + setSpaceGroupName("P1"); + doApplySymmetry = true; + // inputOnly = checkFilter("INPUT"); + } + + + + @Override + protected boolean checkLine() throws Exception { + if (line.contains("Real(R)+Recip(G)")) { + readIntiallattice(); + } + return true; + } + + + private void readIntiallattice() throws Exception { + /* + Real(R)+Recip(G) space primitive vectors, cartesian coordinates (Bohr,Bohr^-1): + R(1)= 25.9374361 0.0000000 0.0000000 G(1)= 0.0385543 0.0222593 0.0000000 + R(2)=-12.9687180 22.4624785 0.0000000 G(2)= 0.0000000 0.0445187 0.0000000 + R(3)= 0.0000000 0.0000000 16.0314917 G(3)= 0.0000000 0.0000000 0.0623772 + Unit cell volume ucvol= 9.3402532E+03 bohr^3 + */ + + cellLattice = new float[9]; + String data = ""; + int counter = 0; + while (readLine() != null && line.indexOf("Unit cell volume") < 0){ + data += line; + data = TextFormat.simpleReplace(data, "=", "= "); + String[] tokens = getTokensStr(data); + cellLattice[counter++] = parseFloatStr(tokens[1]) * ANGSTROMS_PER_BOHR; + cellLattice[counter++] = parseFloatStr(tokens[2]) * ANGSTROMS_PER_BOHR; + cellLattice[counter++] = parseFloatStr(tokens[3]) * ANGSTROMS_PER_BOHR; + counter ++; + } + setSymmetry(); + } + + + private void setSymmetry() throws Exception { + applySymmetryAndSetTrajectory(); + setSpaceGroupName("P1"); + setFractionalCoordinates(false); + } + + + + +} Property changes on: trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pie...@us...> - 2013-09-18 23:03:44
|
Revision: 18667 http://sourceforge.net/p/jmol/code/18667 Author: pierocanepa Date: 2013-09-18 23:03:38 +0000 (Wed, 18 Sep 2013) Log Message: ----------- Abinit reader beginning Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java 2013-09-18 22:59:59 UTC (rev 18666) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java 2013-09-18 23:03:38 UTC (rev 18667) @@ -1,6 +1,5 @@ package org.jmol.adapter.readers.xtal; - /** * http://cms.mpi.univie.ac.at/vasp/ * @@ -11,64 +10,155 @@ * @version 1.0 */ +import org.jmol.adapter.smarter.Atom; import org.jmol.adapter.smarter.AtomSetCollectionReader; import org.jmol.util.TextFormat; public class AbinitReader extends AtomSetCollectionReader { - + private float[] cellLattice; - - + private String spaceGroupName; + private String atomList[]; + @Override protected void initializeReader() { setSpaceGroupName("P1"); doApplySymmetry = true; // inputOnly = checkFilter("INPUT"); } - - - + @Override protected boolean checkLine() throws Exception { - if (line.contains("Real(R)+Recip(G)")) { + if (line.contains("natom")) { + readNoatom(); + } else if (line.contains("ntypat") || line.contains("ntype")) { + readNotypes(); + } else if (line.contains("typat") || line.contains("type")) { + //read sequence of types + readTypesequence(); + } else if (line.contains("Pseudopotential")) { + readAtomSpecies(); + } else if (line.contains("Symmetries :")) { + readSpaceGroup(); + } else if (line.contains("Real(R)+Recip(G)")) { readIntiallattice(); - } + } else if (line.contains("xred")) { + readIntitfinalCoord(); + } return true; } - - + + private int nAtom; + + private void readNoatom() throws Exception { + String[] tokens = getTokensStr(line); + if (tokens.length <= 2) + nAtom = parseIntStr(tokens[1]); + } + + private int nType; + + private void readNotypes() throws Exception { + String[] tokens = getTokensStr(line); + if (tokens.length <= 2) + nType = parseIntStr(tokens[1]); + } + + private int typeArray[]; + + private void readTypesequence() throws Exception { + typeArray = new int[nAtom]; + int i = 0; + while (line != null && line.indexOf("wtk") < 0) { + String tmp = line; + if (line.contains("type")) + tmp = TextFormat.simpleReplace(tmp, "type", ""); + if (line.contains("typat")) + tmp = TextFormat.simpleReplace(tmp, "typat", ""); + + String[] tokens = getTokensStr(tmp); + for (int j = 0; j < tokens.length; j++) { + typeArray[i] = parseIntStr(tokens[j]); + i++; + } + readLine(); + } + } + + private void readAtomSpecies() throws Exception { + atomList = new String[nAtom]; + readLine(); + //- pspini: atom type 1 psp file is Al.psp + String[] pseudo = getTokensStr(line); + int pseudoType = parseIntStr(pseudo[4]); + for (int i = 0; i < nType; i++) { //is this ntype or sequence type ? + int tokenIndex = 0; + discardLinesUntilContains("zion"); + String tmp = TextFormat.simpleReplace(line, ".", " "); + String[] tokens = getTokensStr(tmp); + if (tokens[0] == "-") + tokenIndex = 1; + int atomicNo = parseIntStr(tokens[tokenIndex]); + if (pseudoType == atomicNo) { + for (int j = 0; j < typeArray.length; j++) { + atomList[j] = getElementSymbol(atomicNo); + } + } + } + } + + // Symmetries : space group P4/m m m (#123); Bravais tP (primitive tetrag.) + private void readSpaceGroup() throws Exception { + } + private void readIntiallattice() throws Exception { - /* - Real(R)+Recip(G) space primitive vectors, cartesian coordinates (Bohr,Bohr^-1): - R(1)= 25.9374361 0.0000000 0.0000000 G(1)= 0.0385543 0.0222593 0.0000000 - R(2)=-12.9687180 22.4624785 0.0000000 G(2)= 0.0000000 0.0445187 0.0000000 - R(3)= 0.0000000 0.0000000 16.0314917 G(3)= 0.0000000 0.0000000 0.0623772 - Unit cell volume ucvol= 9.3402532E+03 bohr^3 - */ - + + // Real(R)+Recip(G) space primitive vectors, cartesian coordinates (Bohr,Bohr^-1): + // R(1)= 25.9374361 0.0000000 0.0000000 G(1)= 0.0385543 0.0222593 0.0000000 + // R(2)=-12.9687180 22.4624785 0.0000000 G(2)= 0.0000000 0.0445187 0.0000000 + // R(3)= 0.0000000 0.0000000 16.0314917 G(3)= 0.0000000 0.0000000 0.0623772 + // Unit cell volume ucvol= 9.3402532E+03 bohr^3 + cellLattice = new float[9]; String data = ""; int counter = 0; - while (readLine() != null && line.indexOf("Unit cell volume") < 0){ - data += line; + while (readLine() != null && line.indexOf("Unit cell volume") < 0) { + data = line; data = TextFormat.simpleReplace(data, "=", "= "); String[] tokens = getTokensStr(data); cellLattice[counter++] = parseFloatStr(tokens[1]) * ANGSTROMS_PER_BOHR; cellLattice[counter++] = parseFloatStr(tokens[2]) * ANGSTROMS_PER_BOHR; cellLattice[counter++] = parseFloatStr(tokens[3]) * ANGSTROMS_PER_BOHR; - counter ++; } setSymmetry(); } - - + private void setSymmetry() throws Exception { applySymmetryAndSetTrajectory(); setSpaceGroupName("P1"); setFractionalCoordinates(false); } - - - + //xred -7.0000000000E-02 0.0000000000E+00 0.0000000000E+00 + // 7.0000000000E-02 0.0000000000E+00 0.0000000000E+00 + private void readIntitfinalCoord() throws Exception { + // Read crystallographic coordinate of intial and + // final structures. + String data = ""; + int count = 0; + while (readLine() != null && line.contains("znucl")) { + Atom atom = atomSetCollection.addNewAtom(); + atom.atomName = atomList[count++]; + data = line; + if (data.contains("xred")) + TextFormat.simpleReplace(data, "xred", ""); + String[] tokens = getTokensStr(data); + float x = parseFloatStr(tokens[0]); + float y = parseFloatStr(tokens[1]); + float z = parseFloatStr(tokens[2]); + setAtomCoordXYZ(atom, x, y, z); + } + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2014-01-27 21:24:05
|
Revision: 19219 http://sourceforge.net/p/jmol/code/19219 Author: hansonr Date: 2014-01-27 21:24:00 +0000 (Mon, 27 Jan 2014) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java 2014-01-27 21:08:46 UTC (rev 19218) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java 2014-01-27 21:24:00 UTC (rev 19219) @@ -128,6 +128,7 @@ doSymmetry = false; } + // xcart 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 // 2.5542500000E+00 2.5542500000E+00 2.5542500000E+00 // xred... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2014-01-27 22:22:06
|
Revision: 19220 http://sourceforge.net/p/jmol/code/19220 Author: hansonr Date: 2014-01-27 22:22:00 +0000 (Mon, 27 Jan 2014) Log Message: ----------- ___JmolVersion="14.1.8_dev_2014.01.27" code: reader overhaul for setting atom coordinates in a consistent fashion bug fix: abinit reader was nonfunctional Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java 2014-01-27 21:24:00 UTC (rev 19219) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/AbinitReader.java 2014-01-27 22:22:00 UTC (rev 19220) @@ -71,7 +71,7 @@ private float[] typeArray; private void readTypesequence() throws Exception { - fillFloatArray(line.substring(10), 0, typeArray = new float[nAtom]); + fillFloatArray(line.substring(12), 0, typeArray = new float[nAtom]); } private void readAtomSpecies() throws Exception { @@ -118,14 +118,12 @@ setSpaceGroupName("P1"); for (int i = 0; i < 3; i++) addPrimitiveLatticeVector(i, cellLattice, i * 3); - if (!doSymmetry) - return; Atom[] atoms = atomSetCollection.atoms; int i0 = atomSetCollection.getAtomSetAtomIndex(atomSetCollection.currentAtomSetIndex); - for (int i = atomSetCollection.atomCount; --i >= i0;) - setAtomCoord(atoms[i]); + if (!iHaveFractionalCoordinates) + for (int i = atomSetCollection.atomCount; --i >= i0;) + setAtomCoord(atoms[i]); applySymmetryAndSetTrajectory(); - doSymmetry = false; } @@ -138,9 +136,10 @@ private void readAtoms() throws Exception { // Read cartesian coordinates atomSetCollection.newAtomSet(); + iHaveFractionalCoordinates = false; doSymmetry = true; int i0 = atomSetCollection.atomCount; - line = line.substring(10); + line = line.substring(12); while (line != null && !line.contains("x")) { Atom atom = atomSetCollection.addNewAtom(); setAtomCoordScaled(atom, getTokensStr(line), 0, ANGSTROMS_PER_BOHR); @@ -148,11 +147,11 @@ } discardLinesUntilContains("z"); if (znucl == null) - fillFloatArray(line.substring(11), 0, znucl = new float[nType]); + fillFloatArray(line.substring(12), 0, znucl = new float[nType]); Atom[] atoms = atomSetCollection.atoms; for (int i = 0; i < nAtom; i++) atoms[i + i0].elementNumber = (short) znucl[(int) typeArray[i] - 1]; - applySymmetry(); + applySymmetry(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |