io.g96.in
Class InCorG96

java.lang.Object
  extended byio.g96.in.InBlock
      extended byio.g96.in.InCorG96

public class InCorG96
extends InBlock

Read blocks from a final coordinate (POSITION) or a trajectory (POSITIONRED) file until all requirements are fulfilled. In general (with exceptions, see below), this means, that the following blocks are read: TIMESTEP, POSITION(RED), BOX. The TIMESTEP block in G96 is sort broken for trajectories longer than 100 ns. The box block is not available for vacuum simulations, so attempt to handle that gracefully.

Author:
vincent

Field Summary
private  boolean attemptTimeStepRead
           
private  boolean foundBadTimestep
           
private static boolean foundZeroBox
           
 boolean readFrameSuccessful
           
 
Fields inherited from class io.g96.in.InBlock
endPattern, fileName, startPattern, stream, tok
 
Constructor Summary
InCorG96()
           
InCorG96(java.lang.String fileName)
           
 
Method Summary
static void assertNonDuplicateBlock(java.lang.String blockName, java.util.Set frameKeys)
          If we want to read a block type that we have already read for this frame, it's likely an error.
 java.util.HashMap getFrame(boolean isVacuum)
          Read all the blocks we need to have a valid frame.
 double[] parseBoxBlock(java.util.ArrayList block)
          Parse the (BOX) block and put the stuff into box.
 double[] parseGenBoxBlock(java.util.ArrayList block)
          Parse the (GENBOX) block and put the stuff into box.
static double[][] parsePositionBlock(java.util.ArrayList block)
           
static double[][] parsePositionredBlock(java.util.ArrayList block)
           
 java.util.HashMap parseTimeStepBlock(java.util.ArrayList block)
          Parse a Gromos96 TIMESTEP block.
 G96Frame readFrame()
          Read and parse a Gromos96 frame from file.
 G96Frame readFrame(boolean isVacuum)
           
static boolean skipBlock(java.lang.String blockName)
          We don't care about any blocks except the TIMESTEP, POSITION(RED) and the BOX block.
 
Methods inherited from class io.g96.in.InBlock
assertBlockName, assertBlockSize, close, getBlocks, getNextBlock, open, parseDoubleArray, parseDoubleArray, parseDoubleArray, parseDoubleMatrix, readTitle, skipLine, slurp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

foundBadTimestep

private boolean foundBadTimestep

attemptTimeStepRead

private boolean attemptTimeStepRead

foundZeroBox

private static boolean foundZeroBox

readFrameSuccessful

public boolean readFrameSuccessful
Constructor Detail

InCorG96

public InCorG96()
         throws java.io.IOException
Throws:
java.io.IOException

InCorG96

public InCorG96(java.lang.String fileName)
         throws java.io.IOException
Throws:
java.io.IOException
Method Detail

skipBlock

public static boolean skipBlock(java.lang.String blockName)
We don't care about any blocks except the TIMESTEP, POSITION(RED) and the BOX block. This function is a shorthand to check for that.

Parameters:
blockName -
Returns:
whether we want to skip that block.

assertNonDuplicateBlock

public static void assertNonDuplicateBlock(java.lang.String blockName,
                                           java.util.Set frameKeys)
                                    throws java.io.IOException
If we want to read a block type that we have already read for this frame, it's likely an error. This function throws an IOException if that's the case.

Parameters:
blockName -
frameKeys -
Throws:
java.io.IOException

parseBoxBlock

public double[] parseBoxBlock(java.util.ArrayList block)
                       throws java.io.IOException
Parse the (BOX) block and put the stuff into box. That's it, doodz.

Parameters:
block -
Throws:
java.io.IOException

parseGenBoxBlock

public double[] parseGenBoxBlock(java.util.ArrayList block)
                          throws java.io.IOException
Parse the (GENBOX) block and put the stuff into box. That's it, doodz.

Parameters:
block -
Throws:
java.io.IOException

parsePositionredBlock

public static double[][] parsePositionredBlock(java.util.ArrayList block)
                                        throws java.io.IOException
Parameters:
block -
Returns:
the positions
Throws:
java.io.IOException

parsePositionBlock

public static double[][] parsePositionBlock(java.util.ArrayList block)
                                     throws java.io.IOException
Parameters:
block -
Returns:
the positions
Throws:
java.io.IOException

parseTimeStepBlock

public java.util.HashMap parseTimeStepBlock(java.util.ArrayList block)
                                     throws java.io.IOException
Parse a Gromos96 TIMESTEP block. Watch out for the formatting bug.

Parameters:
block -
Returns:
the time and step values
Throws:
java.io.IOException

getFrame

public java.util.HashMap getFrame(boolean isVacuum)
                           throws java.io.IOException
Read all the blocks we need to have a valid frame. Assumes the following order of blocks TITLE (optional) TIMESTEP (optional) POSITION | POSITIONRED BOX (optional, see isVaccum)

Parameters:
isVacuum - determines whether we should attempt to read a box block (we don't in vacuum)
Returns:
HashMap of (blockNames, blocks)
Throws:
java.io.IOException

readFrame

public G96Frame readFrame()
                   throws java.io.IOException
Read and parse a Gromos96 frame from file.

Returns:
the next frame
Throws:
java.io.IOException

readFrame

public G96Frame readFrame(boolean isVacuum)
                   throws java.io.IOException
Throws:
java.io.IOException