Documentation of 'edu.rit.clu.antimatter.AntiprotonFile' Java class
AntiprotonFile
edu.rit.clu.antimatter

Class AntiprotonFile



  • public class AntiprotonFile
    extends java.lang.Object
    Class AntiprotonFile provides an object for reading or writing a series of snapshots of antiproton positions from or to a file.

    To write the snapshots to a file, call the prepareToWrite() method, specifying the output stream to write. The prepareToWrite() method returns an instance of class AntiprotonFile.Writer. Call the methods of the writer object to write the antiproton position snapshots to the output stream. When finished, close the writer.

    To read the snapshots from a file, call the prepareToRead() method, specifying the input stream to read. The prepareToRead() method returns an instance of class AntiprotonFile.Reader. Call the methods of the reader object to read the antiproton position snapshots from the input stream. When finished, close the reader.

    Class AntiprotonFile includes a main program to combine a group of antiproton files into one antiproton file. You might use this main program when the processes of a parallel program have computed slices of the antiprotons and stored the slices in separate files, and you want to combine the slices together into one file.

    Antiproton File Format

    An antiproton file is a binary file containing the following items. Each primitive item is written as though by java.io.DataOutput (int, four bytes; long, eight bytes; double, eight bytes; most significant byte first).

    • Random seed used to generate the initial antiproton positions, seed (long).
    • Side of the square used to generate the initial antiproton positions, R (double).
    • Time step size, dt (double).
    • Number of time steps between snapshots, steps (int).
    • Number of snapshots, snaps (int).
    • Total number of antiprotons, N (int).
    • Lower antiproton index for each snapshot, L (int). L >= 0.
    • Number of antiprotons in each snapshot, M (int). M >= 0. L+M <= N.
    • The snapshots.

    Each snapshot contains the following items. A snapshot contains information about a slice of the antiprotons.

    • The antiproton positions for antiproton indexes L .. L+M-1. Each position is stored as the X coordinate (double) followed by the Y coordinate (double).
    • The total momentum for the antiprotons at antiproton indexes L .. L+M-1. Stored as the X coordinate (double) followed by the Y coordinate (double).
    • Constructor Summary

      Constructors 
      Constructor and Description
      AntiprotonFile()
      Construct a new antiproton file object.
      AntiprotonFile(long seed, double R, double dt, int steps, int snaps, int N, int L, int M)
      Construct a new antiproton file object with the given attributes.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      double getDt()
      Get the time step size.
      int getL()
      Get the lower antiproton index for each snapshot.
      int getM()
      Get the number of antiprotons in each snapshot.
      int getN()
      Get the total number of antiprotons.
      double getR()
      Get the side of the square used to generate the initial antiproton positions.
      long getSeed()
      Get the random seed used to generate the initial antiproton positions.
      int getSnaps()
      Get the number of snapshots.
      int getSteps()
      Get the number of time steps between snapshots.
      static void main(java.lang.String[] args)
      Main program to combine a group of antiproton files into one antiproton file.
      AntiprotonFile.Reader prepareToRead(java.io.InputStream theStream)
      Prepare to read this antiproton file from the given input stream.
      AntiprotonFile.Writer prepareToWrite(java.io.OutputStream theStream)
      Prepare to write this antiproton file to the given output stream.
      void setAttributes(long seed, double R, double dt, int steps, int snaps, int N, int L, int M)
      Set this antiproton file's attributes.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AntiprotonFile

        public AntiprotonFile()
        Construct a new antiproton file object. The antiproton file's attributes are uninitialized. Before using the antiproton file, specify the attributes by calling the setAttributes() method or by reading the antiproton file from an input stream.
      • AntiprotonFile

        public AntiprotonFile(long seed,
                              double R,
                              double dt,
                              int steps,
                              int snaps,
                              int N,
                              int L,
                              int M)
        Construct a new antiproton file object with the given attributes.
        Parameters:
        seed - Random seed used to generate the initial antiproton positions.
        R - Side of the square used to generate the initial antiproton positions.
        dt - Time step size.
        steps - Number of time steps between snapshots.
        snaps - Number of snapshots.
        N - Total number of antiprotons.
        L - Lower antiproton index for each snapshot.
        M - Number of antiprotons in each snapshot.
        Throws:
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if R <= 0. Thrown if dt <= 0. Thrown if steps <= 0. Thrown if snaps < 0. Thrown if N < 0.
        java.lang.IndexOutOfBoundsException - (unchecked exception) Thrown if L < 0. Thrown if M < 0. Thrown if L+M > N.
    • Method Detail

      • getSeed

        public long getSeed()
        Get the random seed used to generate the initial antiproton positions.
        Returns:
        Random seed, seed.
      • getR

        public double getR()
        Get the side of the square used to generate the initial antiproton positions.
        Returns:
        Side, R.
      • getDt

        public double getDt()
        Get the time step size.
        Returns:
        Time step size, dt.
      • getSteps

        public int getSteps()
        Get the number of time steps between snapshots.
        Returns:
        Number of time steps, steps.
      • getSnaps

        public int getSnaps()
        Get the number of snapshots.
        Returns:
        Number of snapshots, snaps.
      • getN

        public int getN()
        Get the total number of antiprotons.
        Returns:
        Total number of antiprotons, N.
      • getL

        public int getL()
        Get the lower antiproton index for each snapshot.
        Returns:
        Lower antiproton index for each snapshot, L.
      • getM

        public int getM()
        Get the number of antiprotons in each snapshot.
        Returns:
        Number of antiprotons in each snapshot, M.
      • setAttributes

        public void setAttributes(long seed,
                                  double R,
                                  double dt,
                                  int steps,
                                  int snaps,
                                  int N,
                                  int L,
                                  int M)
        Set this antiproton file's attributes.
        Parameters:
        seed - Random seed used to generate the initial antiproton positions.
        R - Side of the square used to generate the initial antiproton positions.
        dt - Time step size.
        steps - Number of time steps between snapshots.
        snaps - Number of snapshots.
        N - Total number of antiprotons.
        L - Lower antiproton index for each snapshot.
        M - Number of antiprotons in each snapshot.
        Throws:
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if R <= 0. Thrown if dt <= 0. Thrown if steps <= 0. Thrown if snaps < 0. Thrown if N < 0.
        java.lang.IndexOutOfBoundsException - (unchecked exception) Thrown if L < 0. Thrown if M < 0. Thrown if L+M > N.
      • prepareToWrite

        public AntiprotonFile.Writer prepareToWrite(java.io.OutputStream theStream)
                                             throws java.io.IOException
        Prepare to write this antiproton file to the given output stream. This matrix file's attributes are written to the output stream at this time. To write this antiproton file's snapshots, call methods on the returned writer, then close the writer.

        For improved performance, specify an output stream with buffering, such as an instance of class java.io.BufferedOutputStream.

        Parameters:
        theStream - Output stream.
        Returns:
        Writer object with which to write this antiproton file.
        Throws:
        java.lang.IllegalStateException - (unchecked exception) Thrown if this antiproton file object is uninitialized.
        java.lang.NullPointerException - (unchecked exception) Thrown if theStream is null.
        java.io.IOException - Thrown if an I/O error occurred.
      • prepareToRead

        public AntiprotonFile.Reader prepareToRead(java.io.InputStream theStream)
                                            throws java.io.IOException
        Prepare to read this antiproton file from the given input stream. This antiproton file's attributes are read from the input stream at this time. To read this antiproton file's snapshots, call methods on the returned reader, then close the reader.

        For improved performance, specify an input stream with buffering, such as an instance of class java.io.BufferedInputStream.

        Parameters:
        theStream - Input stream.
        Returns:
        Reader object with which to read this antiproton file.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theStream is null.
        java.io.IOException - Thrown if an I/O error occurred.
      • main

        public static void main(java.lang.String[] args)
                         throws java.lang.Exception
        Main program to combine a group of antiproton files into one antiproton file. Each input file must be for an antiproton array with the same number of elements. Each input file must contain the same number of snapshots.

        You might use this main program when the processes of a parallel program have computed slices of antiprotons and stored the slices in separate files, and you want to combine the slices together into one file.

        Usage: java edu.rit.io.AntiprotonFile outfile infile1 [ infile2 . . . ]

        Throws:
        java.lang.Exception

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.