From: <ha...@us...> - 2010-02-18 15:05:02
|
Revision: 12406 http://jmol.svn.sourceforge.net/jmol/?rev=12406&view=rev Author: hansonr Date: 2010-02-18 15:04:53 +0000 (Thu, 18 Feb 2010) Log Message: ----------- preliminary CRYSTAL reader -- requires CRYSTAL:: prefix in LOAD command. Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/xtal/CrystalReader.java trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/CrystalReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/CrystalReader.java 2010-02-18 13:44:51 UTC (rev 12405) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/CrystalReader.java 2010-02-18 15:04:53 UTC (rev 12406) @@ -5,9 +5,9 @@ * * Contact: jmo...@li... * - * Copyright (C) 2009 Joerg Meyer, FHI Berlin + * Copyright (C) 2009 Piero Canepa, University of Kent , UK * - * Contact: me...@fh... + * Contact: pc...@ke... or pie...@gm... * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -31,61 +31,83 @@ import java.io.BufferedReader; /** - * - * http://www.cse.clrc.ac.uk/cmg/CRYSTAL/ - * - * very preliminary -- untested - * - * + * + * http://www.crystal.unito.it/ + * + * @author Pieremanuele Canepa, Room 104, FM Group + * School of Physical Sciences, Ingram Building, + * University of Kent, Canterbury, Kent, + * CT2 7NH + * United Kingdom + * + * @version 1.0 + * + * This version works and has been well tested on several structures! + * */ public class CrystalReader extends AtomSetCollectionReader { - public void readAtomSetCollection(BufferedReader reader) { + public void readAtomSetCollection(BufferedReader reader) { - atomSetCollection = new AtomSetCollection("Crystal", this); - try { - this.reader = reader; - atomSetCollection.setCollectionName(readLine()); - while (readLine() != null) { - if (line.startsWith(" MOLECULE")) { - readAtomCoords(false); - break; - } - if (line.startsWith(" CRYSTAL") || line.startsWith(" SLAB") - || line.startsWith(" POLYMER") || line.startsWith(" EXTERNAL")) { - atomSetCollection.setAtomSetAuxiliaryInfo("periodicity", line); - readCellParams(); - readAtomCoords(true); - break; - } - } - - applySymmetryAndSetTrajectory(); - - } catch (Exception e) { - setError(e); - } - } + boolean isthisPeriodic=false ; - private void readCellParams() throws Exception { + atomSetCollection = new AtomSetCollection("Crystal", this); + try { + this.reader = reader; + atomSetCollection.setCollectionName(readLine()); + while (readLine() != null) { + if (line.startsWith("MOLECULE")) { + isthisPeriodic=false; + readAtomCoords(false,isthisPeriodic); - discardLinesUntilContains(" LATTICE PARAMETERS (ANGSTROMS AND DEGREES) - PRIMITIVE CELL"); - readLine(); - readLine(); - float a = parseFloat(line.substring(2, 17)); - float b = parseFloat(line.substring(18, 33)); - float c = parseFloat(line.substring(34, 42)); - float alpha = parseFloat(line.substring(43, 60)); - float beta = parseFloat(line.substring(61, 71)); - float gamma = parseFloat(line.substring(72, 80)); - // this method works fine so far - setUnitCell(a, b, c, alpha, beta, gamma); - } + break; + } + if (line.startsWith("CRYSTAL") || line.startsWith("SLAB") + || line.startsWith("POLYMER") || line.startsWith("EXTERNAL")) { + atomSetCollection.setAtomSetAuxiliaryInfo("periodicity", line); + isthisPeriodic=true; + readCellParams(); + readAtomCoords(true, isthisPeriodic); - private void readAtomCoords(boolean isFractional) throws Exception { + break; + } + } + + applySymmetryAndSetTrajectory(); + + } catch (Exception e) { + setError(e); + } + } + + private void readCellParams() throws Exception { + + discardLinesUntilStartsWith(" PRIMITIVE CELL"); + readLine(); + readLine(); + float a = parseFloat(line.substring(2,17)) ; + float b = parseFloat(line.substring(16,33)) ; + float c = parseFloat(line.substring(33,42)); + + if (b == 500.00000){ + b = 1; + } + + if (c == 500.0000){ + c = 1; + } + float alpha = parseFloat(line.substring(48,58)) ; + float beta = parseFloat(line.substring(59,69)) ; + float gamma = parseFloat(line.substring(70,80)) ; + + setUnitCell(a, b, c, alpha, beta, gamma); + } + + private void readAtomCoords(boolean isFractional, boolean isthisPeriodic) + throws Exception { setFractionalCoordinates(isFractional); - discardLinesUntilContains("ATOMS IN THE ASYMMETRIC"); + discardLinesUntilContains(" ATOMS IN THE ASYMMETRIC"); int atomCount = parseInt(line.substring(61, 65)); readLine(); readLine(); @@ -96,6 +118,19 @@ float x = parseFloat(line.substring(15, 35)); float y = parseFloat(line.substring(36, 55)); float z = parseFloat(line.substring(56, 75)); + + if (x < 0 && isthisPeriodic) { + x = 1 + x; + } + + if (y < 0 && isthisPeriodic) { + y = 1 + y; + } + + if (z < 0 && isthisPeriodic) { + z = 1 + z; + } + Atom atom = atomSetCollection.addNewAtom(); setAtomCoord(atom, x, y, z); atom.elementSymbol = getElementSymbol(atomicnumber); Modified: trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2010-02-18 13:44:51 UTC (rev 12405) +++ trunk/Jmol/src/org/jmol/adapter/smarter/Resolver.java 2010-02-18 15:04:53 UTC (rev 12406) @@ -537,24 +537,25 @@ private final static int SPECIAL_WIEN = 9; private final static int SPECIAL_CASTEP = 10; private final static int SPECIAL_AIMS = 11; + final static int SPECIAL_CRYSTAL = 12; // these next are needed by the XML reader - public final static int SPECIAL_ARGUS_XML = 12; - public final static int SPECIAL_CML_XML = 13; - public final static int SPECIAL_CHEM3D_XML = 14; - public final static int SPECIAL_MOLPRO_XML = 15; - public final static int SPECIAL_ODYSSEY_XML = 16; - public final static int SPECIAL_XSD_XML = 17; - public final static int SPECIAL_VASP_XML = 18; + public final static int SPECIAL_ARGUS_XML = 13; + public final static int SPECIAL_CML_XML = 14; + public final static int SPECIAL_CHEM3D_XML = 15; + public final static int SPECIAL_MOLPRO_XML = 16; + public final static int SPECIAL_ODYSSEY_XML = 17; + public final static int SPECIAL_XSD_XML = 18; + public final static int SPECIAL_VASP_XML = 19; - public final static int SPECIAL_ARGUS_DOM = 19; - public final static int SPECIAL_CML_DOM = 20; - public final static int SPECIAL_CHEM3D_DOM = 21; - public final static int SPECIAL_MOLPRO_DOM = 22; - public final static int SPECIAL_ODYSSEY_DOM = 23; - public final static int SPECIAL_XSD_DOM = 24; // not implemented - public final static int SPECIAL_VASP_DOM = 25; + public final static int SPECIAL_ARGUS_DOM = 20; + public final static int SPECIAL_CML_DOM = 21; + public final static int SPECIAL_CHEM3D_DOM = 22; + public final static int SPECIAL_MOLPRO_DOM = 23; + public final static int SPECIAL_ODYSSEY_DOM = 24; + public final static int SPECIAL_XSD_DOM = 25; // not implemented + public final static int SPECIAL_VASP_DOM = 26; public final static String[][] specialTags = { { "Jme" }, @@ -571,6 +572,7 @@ { "Castep" }, { "Aims" }, + { "Crystal" }, { "XmlArgus" }, //12 { "XmlCml" }, @@ -975,15 +977,12 @@ private final static String[] uicrcifContainsRecords = { "Cif", "Crystallographic Information File"}; - private final static String[] crystalContainsRecords = - { "Crystal", " - DIMENSIONALITY OF THE SYSTEM" }; - private final static String[][] containsRecords = { xmlContainsRecords, gaussianContainsRecords, ampacContainsRecords, mopacContainsRecords, qchemContainsRecords, gamessUKContainsRecords, gamessUSContainsRecords, spartanBinaryContainsRecords, spartanContainsRecords, mol2Records, adfContainsRecords, psiContainsRecords, - nwchemContainsRecords, uicrcifContainsRecords, dgridContainsRecords, crystalContainsRecords + nwchemContainsRecords, uicrcifContainsRecords, dgridContainsRecords }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |