Revision: 20114 http://sourceforge.net/p/jmol/code/20114 Author: hansonr Date: 2014-11-19 11:47:35 +0000 (Wed, 19 Nov 2014) Log Message: -----------
Added Paths: ----------- branches/v14_2/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java branches/v14_2/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java branches/v14_2/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.java Added: branches/v14_2/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java =================================================================== --- branches/v14_2/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java (rev 0) +++ branches/v14_2/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java 2014-11-19 11:47:35 UTC (rev 20114) @@ -0,0 +1,96 @@ +/* $RCSfile$ + * $Author: hansonr $ + * + * Copyright (C) 2003-2005 Miguel, Jmol Development, www.jmol.org + * + * Contact: jmol-develop...@lists.sf.net + * + * Copyright (C) 2009 Piero Canepa, University of Kent, UK + * + * Contact: pc...@kent.ac.uk or pieremanuele.can...@gmail.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +package org.jmol.adapter.readers.xtal; + +import org.jmol.adapter.smarter.AtomSetCollectionReader; + +/** + * http://cms.mpi.univie.ac.at/vasp/vasp/CHGCAR_file.html + * + * very simple reader of just the header information. + * + */ + +public class VaspChgcarReader extends AtomSetCollectionReader { + + @Override + protected void initializeReader() { + setSpaceGroupName("P1"); + setFractionalCoordinates(true); + } + +// Na Cl +// 5.68452685100000 +// 1.000000 0.000000 0.000000 +// 0.000000 1.000000 0.000000 +// 0.000000 0.000000 1.000000 +// 4 4 +//Direct +// 0.750000 0.250000 0.250000 +// 0.250000 0.750000 0.250000 +// 0.250000 0.250000 0.750000 +// 0.750000 0.750000 0.750000 +// 0.250000 0.250000 0.250000 +// 0.750000 0.750000 0.250000 +// 0.750000 0.250000 0.750000 +// 0.250000 0.750000 0.750000 +// + + @Override + protected boolean checkLine() throws Exception { + String[] atomSym = getTokens(); + float scale = parseFloatStr(rd()); + float[] unitCellData = new float[9]; + fillFloatArray(null, 0, unitCellData); + for (int i = 0; i < 9; i++) + unitCellData[i] *= scale; + addPrimitiveLatticeVector(0, unitCellData, 0); + addPrimitiveLatticeVector(1, unitCellData, 3); + addPrimitiveLatticeVector(2, unitCellData, 6); + String[] tokens = getTokensStr(rd()); + int[] atomCounts = new int[tokens.length]; + for (int i = tokens.length; --i >= 0;) + atomCounts[i] = parseIntStr(tokens[i]); + if (atomSym.length != atomCounts.length) + atomSym = null; + /*String type = */ rd(); + // type should be "direct" + for (int i = 0; i < atomCounts.length; i++) + for (int j = atomCounts[i]; --j >= 0;) + addAtomXYZSymName(getTokensStr(rd()), 0, (atomSym == null ? "Xx" : atomSym[i]), null); + continuing = false; + return false; + } + + @Override + protected void finalizeSubclassReader() throws Exception { + applySymmetryAndSetTrajectory(); + } + + +} Property changes on: branches/v14_2/Jmol/src/org/jmol/adapter/readers/xtal/VaspChgcarReader.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: branches/v14_2/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java =================================================================== --- branches/v14_2/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java (rev 0) +++ branches/v14_2/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java 2014-11-19 11:47:35 UTC (rev 20114) @@ -0,0 +1,52 @@ +package org.jmol.jvxl.readers; + +public abstract class PeriodicVolumeFileReader extends VolumeFileReader { + + @Override + protected void readSurfaceData(boolean isMapData) throws Exception { + initializeSurfaceData(); + voxelData = new float[nPointsX][nPointsY][nPointsZ]; + readSkip(); + getPeriodicVoxels(); + + // add in periodic face data + + int n; + n = nPointsX - 1; + for (int i = 0; i < nPointsY; ++i) + for (int j = 0; j < nPointsZ; ++j) + voxelData[n][i][j] = voxelData[0][i][j]; + n = nPointsY - 1; + for (int i = 0; i < nPointsX; ++i) + for (int j = 0; j < nPointsZ; ++j) + voxelData[i][n][j] = voxelData[i][0][j]; + n = nPointsZ - 1; + for (int i = 0; i < nPointsX; ++i) + for (int j = 0; j < nPointsY; ++j) + voxelData[i][j][n] = voxelData[i][j][0]; + + // for map data, just pick out near points and get rid of voxelData + + if (isMapData && volumeData.hasPlane()) { + volumeData.setVoxelMap(); + for (int x = 0; x < nPointsX; ++x) { + for (int y = 0; y < nPointsY; ++y) { + for (int z = 0; z < nPointsZ; ++z) { + float f = volumeData.getToPlaneParameter(); + if (volumeData.isNearPlane(x, y, z, f)) + volumeData.setVoxelMapValue(x, y, z, voxelData[x][y][z]); + } + } + } + voxelData = null; + } + volumeData.setVoxelDataAsArray(voxelData); + + if (dataMin > params.cutoff) + params.cutoff = 2 * dataMin; + } + + protected abstract void getPeriodicVoxels() throws Exception; + protected abstract void readSkip() throws Exception; + +} Property changes on: branches/v14_2/Jmol/src/org/jmol/jvxl/readers/PeriodicVolumeFileReader.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: branches/v14_2/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.java =================================================================== --- branches/v14_2/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.java (rev 0) +++ branches/v14_2/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.java 2014-11-19 11:47:35 UTC (rev 20114) @@ -0,0 +1,128 @@ +/* $RCSfile$ + * $Author: hansonr $ + * $Date: 2007-03-30 11:40:16 -0500 (Fri, 30 Mar 2007) $ + * $Revision: 7273 $ + * + * Copyright (C) 2007 Miguel, Bob, Jmol Development + * + * Contact: hans...@stolaf.edu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jmol.jvxl.readers; + +import java.io.BufferedReader; + +import org.jmol.util.SimpleUnitCell; + +import javajs.util.SB; + +class VaspChgcarReader extends PeriodicVolumeFileReader { + + private float volume; + + VaspChgcarReader(){ + } + + @Override + void init2(SurfaceGenerator sg, BufferedReader br) { + init2VFR(sg, br); + isAngstroms = true; + nSurfaces = 1; + canDownsample = isProgressive = false; // for now + } + + // pt + // 10.0000000000000 + // 1.000000 0.000000 0.000000 + // 0.000000 1.000000 0.000000 + // 0.000000 0.000000 1.000000 + // 2 4 + //Direct + // 0.080067 0.160200 0.131800 + // 0.213232 0.160200 0.131800 + // 0.022723 0.101273 0.060100 + // 0.022724 0.219127 0.203500 + // 0.270578 0.101273 0.060100 + // 0.270577 0.219127 0.203499 + // + // 140 140 140 + //0.12994340141E+02 0.13765428641E+02 0.14355609008E+02 0.14732384059E+02 0.14873912610E+02 + +// WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,NGXC),NY=1,NGYZ),NZ=1,NGZC) +// +// The x index is the fastest index, and the z index the slowest index. +// The file can be read format-free, because at least in new versions, +// it is guaranteed that spaces separate each number. Please do not forget +// to divide by the volume before visualizing the file! + + @Override + protected void readParameters() throws Exception { + jvxlFileHeaderBuffer = new SB(); + jvxlFileHeaderBuffer.append("Vasp CHGCAR format\n"); + rd(); // atoms + float scale = parseFloatStr(rd()); + float[] data = new float[15]; + data[0] = -1; + for (int i = 0, pt = 6; i < 3; ++i) + volumetricVectors[i].set(data[pt++] = parseFloatStr(rd()) * scale, + data[pt++] = parseFloat() * scale, data[pt++] = parseFloat() * scale); + volume = (float) SimpleUnitCell.newA(data).volume; + // v0 here will be the slowest, not the fastest + while (rd().length() > 2) { + } + rd(); + String[] counts = getTokens(); + for (int i = 0; i < 3; ++i) { + volumetricVectors[i] + .scale(1f / ((voxelCounts[i] = parseIntStr(counts[i]) + 1) - 1)); + if (isAnisotropic) + setVectorAnisotropy(volumetricVectors[i]); + } + swapXZ(); + volumetricOrigin.set(0, 0, 0); + } + + private int pt; + + @Override + protected float nextVoxel() throws Exception { + if ((pt++)%5 == 0) { + rd(); + next[0] = 0; + } + return parseFloat() / volume; + } + + @Override + protected void getPeriodicVoxels() throws Exception { + int ni = voxelCounts[0] - 1; + int nj = voxelCounts[1] - 1; + int nk = voxelCounts[2] - 1; + for (int i = 0; i < ni; i++) + for (int j = 0; j < nj; j++) + for (int k = 0; k < nk; k++) + voxelData[i][j][k] = recordData(nextVoxel()); + } + + @Override + protected void readSkip() throws Exception { + // n/a + } + + +} + + Property changes on: branches/v14_2/Jmol/src/org/jmol/jvxl/readers/VaspChgcarReader.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. ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits