PSCF v1.1
Public Member Functions | List of all members
pscfpp.output.Sweep Class Reference

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...
 

Detailed Description

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/':

from pscfpp.output import *
s = Sweep('out/')
Module of parsers for PSCF output file formats.
Definition: output.py:1

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.

Definition at line 483 of file output.py.

Constructor & Destructor Documentation

◆ __init__()

def pscfpp.output.Sweep.__init__ (   self,
  prefix 
)

Constructor.

The input parameter prefix is the baseFileName prefix string.

Parameters
prefixstring 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().

Member Function Documentation

◆ summary()

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

vals = s.summary(['param.Mixture.Polymer[0].phi','thermo.pressure'])

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

[[0.5, 32.4415250701], [0.55, 30.6782301376],
[0.6, 28.8344576024], [0.65, 26.8019750534],
[0.7, 24.5205812724]]

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

s.summary(['param.Interaction.chi[0][1]'], index = True)

applied to a sweep that changes the indicated chi parameter will return an array that may look something like the following:

[[0, 12.0], [1, 13.0], [2, 14.0], [3, 15.0], [4, 16.0]]

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.

Parameters
varslist of variable name strings in dot notation
indexif 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().

◆ summaryString()

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

report = s.summaryString(['param.Interaction.chi[0][1]',
'thermo.fHelmholtz']))
print(report)

yields an output that looks somethink like this.

step chi[0][1] fHelmholtz
0 1.2000000e+01 1.9256750e+00
1 1.3000000e+01 2.1102042e+00
2 1.4000000e+01 2.2716872e+00
3 1.5000000e+01 2.4158122e+00
4 1.6000000e+01 2.5464487e+00


The string returned by summaryString can also be written to a file.

Parameters
varslist 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().

◆ __getitem__()

def pscfpp.output.Sweep.__getitem__ (   self,
  key 
)

◆ __len__()

def pscfpp.output.Sweep.__len__ (   self)

The documentation for this class was generated from the following file: