PSCF v1.1
|
Container for data in state files produced by a PSCF sweep. More...
Public Member Functions | |
def | __init__ (self, prefix) |
Constructor. More... | |
def | summary (self, vars, index=False) |
Make a summary report containing values for selected variables. More... | |
def | summaryString (self, vars) |
Return a summary report as a formatted string suitable for printing. More... | |
def | __getitem__ (self, key) |
Get a specific State object, specified by integer index. More... | |
def | __len__ (self) |
Get the number of states in a sweep. More... | |
Container for data in state files produced by a PSCF sweep.
A Sweep is a container for all the data contained in the PSCF state files created by a sweep. The data contained in each state file is stored in an instance of class State (full name pscfpp.state.State). Individual state objects within a Sweep can be accessed using a square-bracket syntax, like elements of a python list. Methods summary and summaryString return summary reports containing values of selected variables.
Construction:
The constructor for class Sweep parses and stores the contents of all of the the state files (which end with '.dat') produced by a PSCF sweep. The constructor takes a single argument which is the baseFileName prefix string.
Example: To read and parse all states files produced by a Sweep with the baseFileNAme prefix string 'out/':
Accessing elements:
A Sweep object can be treated as a list of State objects, each of which contains the contents of a corresponding state file. Each state object can be accessed by a corresponding index with square brackets, like an element of a list, such s[0] or s[1].
All elements and properties in each such State object can be accessed using the dot notation for attributes of a State object, such as s[0].param.Mixture.nMonomer or s[1].thermo.fHelmholtz. See the documentation for class pscfpp.state.State for details.
Summary reports:
See documentation for methods summary and summaryString.
def pscfpp.output.Sweep.__init__ | ( | self, | |
prefix | |||
) |
Constructor.
The input parameter prefix is the baseFileName prefix string.
prefix | string that is prefixed to all state file names |
Definition at line 492 of file output.py.
References pscfpp.output.Sweep.sweep, Pscf::Fd1d::System.sweep(), Pscf::SweepTmpl< BasisFieldState< D > >.sweep(), Pscf::SweepTmpl< State >.sweep(), Pscf::SweepTmpl< DArray< System::WField > >.sweep(), Pscf::Pspc::System< D >.sweep(), and Pscf::Pspg::System< D >.sweep().
def pscfpp.output.Sweep.summary | ( | self, | |
vars, | |||
index = False |
|||
) |
Make a summary report containing values for selected variables.
This function constructs a data structure containing the values of a user-specified set of variables at each state in the sweep.
Specifying a list of variable names:
The input parameter vars is a list of strings that specify the variables of interest. Each element in this list is a string that gives the the name of an attribute of a single State object, starting with either 'param' or 'thermo', using a dot notation. For example "param.Mixture.nMonomer" specifies the input parameter nMonomer of the Mixture block of the parameter section of the state file, while "thermo.fHelmoltz" is the free energy per monomer reference volume.
Return value:
The quantity returned by this function is a list in which each element is itself a list of values of values of the specified variables at a single state point. If the return value is assigned to a variable named "summary" then summary[2] is a list of values of the chosen variables at state 2.
The state index (e.g., 2) may optionally be added as the first element of this list of variable values, by setting the optional parameter index to True. By default index = False, so no index numbers are not included when this parameter is absent.
Example:
If s is a Sweep object representing a mixture that has been subjected to a sweep that changes composition, then the command
constructs list named vals of values for the volume fraction for the first polymer species and the non-dimensionalized pressure of the system, for each state in the sweep. In this example, the resulting quantity vals is a list of lists something like
In this example, the value of vals[2] is a python list of two floats, given by [0.6, 28.8344576024], in which the first element (0.6) is the value of phi (volume fraction) for polymer 0 and the second element (28.8344) is the value of the non-dimensionalized pressure, both evaluated in state 2 (the third state in the sweep).
Example:
Adding a final parameter index = True will add the state index as an additional first element of the list of values for each state. For example, the command
applied to a sweep that changes the indicated chi parameter will return an array that may look something like the following:
Here the first value for each state is the integer state index, and the second is the value of the chi parameter chi[0][1] for interactions between monomers of types 0 and 1.
vars | list of variable name strings in dot notation |
index | if True, add the state index as the first variable |
Definition at line 573 of file output.py.
References pscfpp.output.Sweep.sweep, Pscf::Fd1d::System.sweep(), Pscf::SweepTmpl< BasisFieldState< D > >.sweep(), Pscf::SweepTmpl< State >.sweep(), Pscf::SweepTmpl< DArray< System::WField > >.sweep(), Pscf::Pspc::System< D >.sweep(), and Pscf::Pspg::System< D >.sweep().
def pscfpp.output.Sweep.summaryString | ( | self, | |
vars | |||
) |
Return a summary report as a formatted string suitable for printing.
This method produced a formatted string containing the same type of summary report that is generated by the summary method, giving values of selected variables for every state in a sweep. The parameter vars is a list of variable name strings formatted in dot notation, exactly as for the corresponding parameter of the Sweep.summary method. The format includes labels for the variable names and includes a state index for each state.
Example: If applied to a sweep with 5 state points, the command
yields an output that looks somethink like this.
The string returned by summaryString can also be written to a file.
vars | list of variable name strings in dot notation |
Definition at line 627 of file output.py.
References pscfpp.output.Sweep.sweep, Pscf::Fd1d::System.sweep(), Pscf::SweepTmpl< BasisFieldState< D > >.sweep(), Pscf::SweepTmpl< State >.sweep(), Pscf::SweepTmpl< DArray< System::WField > >.sweep(), Pscf::Pspc::System< D >.sweep(), and Pscf::Pspg::System< D >.sweep().
def pscfpp.output.Sweep.__getitem__ | ( | self, | |
key | |||
) |
Get a specific State object, specified by integer index.
key | integer state index. |
Definition at line 701 of file output.py.
References pscfpp.output.Sweep.sweep, Pscf::Fd1d::System.sweep(), Pscf::SweepTmpl< BasisFieldState< D > >.sweep(), Pscf::SweepTmpl< State >.sweep(), Pscf::SweepTmpl< DArray< System::WField > >.sweep(), Pscf::Pspc::System< D >.sweep(), and Pscf::Pspg::System< D >.sweep().
def pscfpp.output.Sweep.__len__ | ( | self | ) |
Get the number of states in a sweep.
Definition at line 707 of file output.py.
References pscfpp.output.Sweep.sweep, Pscf::Fd1d::System.sweep(), Pscf::SweepTmpl< BasisFieldState< D > >.sweep(), Pscf::SweepTmpl< State >.sweep(), Pscf::SweepTmpl< DArray< System::WField > >.sweep(), Pscf::Pspc::System< D >.sweep(), and Pscf::Pspg::System< D >.sweep().