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

Parser and container for PSCF thermo file blocks. More...

Public Member Functions

def __init__ (self, filename=None)
 Constructor. More...
 
def read (self, file)
 Read the passed-in open-file. More...
 
def skipEmptyLine (self, file)
 Skip empty lines in the file. More...
 
def write (self, filename)
 Write the contents of this object in thermo file format to a file. More...
 
def __str__ (self)
 Return a string representation of this object in thermo file format. More...
 

Detailed Description

Parser and container for PSCF thermo file blocks.

This module provides tools to parse the PSCF "thermo" file format and store the contents of a such a file block in accessible form. This file reports properties that are outputs of a SCFT calculation, such as Helmholtz free energy and macroscopic pressure (or grand canonical free energy density), as well as some quantities that can be either inputs or outputs depending on the mode of operation (e.g., chemical potentials and volume fractions). A thermo file block can appear either as the entire contents of a file (which can be created by the PSCF command WRITE_THERMO) or as a section of a larger data (i.e., as part of the log file that is written to standard output at the end of an SCFT or a section of the type of "state" file created by a Sweep operation). Users can access and modify values of properties stored in a Thermo object after it has been used to parse a thermo file block using the Python dot syntax for object attributes.

Construction and Parsing:

Users may parse a thermo file block file by creating a Thermo object, passing either the name of the thermo file or an open file object as an argument. This constructor parses the file and returns a Thermo object that contains its contents.

For example: To read and parse a thermo file with name 'thermo', one could enter:

from pscfpp.output import *
t = Thermo('thermo')
Module of parsers for PSCF output file formats.
Definition: output.py:1

Writing out:

A multi-line string representation of a Thermo object in thermo file format (i.e., the format of the original input file), can be obtained using the str special method, or written to a file using the write method.

Example: If t is a Thermo object, then

t.write('thermoOut')

writes the contents of to file named 'thermoOut'.

Accessing properties:

After creating a Thermo object, users can retrieve the values of any property by name, using a dot notation for properties stored within the Thermo object. There are three different types of properties that are stored within a Thermo object. These are listed below, along with a summary of what is returned when they are accessed, and an example Python expression that would access this type of property in a typical Thermo object:

Single variable: if a property is represented by a single value, such as Helmholtz free energy, it can be accessed using dot notation for a Python attribute. For example, if t is a Thermo object, then the expressions

t.fHelmholtz
t.pressure

return the Helmholtz free energy per monomer in thermal units (property fHelmholtz) and the non-dimensionalized pressure (pressure times monomer reference volume in thermal units).

Arrays of Species objects: the Thermo class has two data attributes named Polymers and Solvents, each of which is a list of instances of class Species. Each Species object represents one polymer or solvent species, and has two data attributes: phi (volume fraction) and mu (chemical potential). A specific Species from the list Polymer or Solvent is accessed by square indexing, which returns the Species object. Dot notation for attributes of a Species can then be used to access the value of phi or mu for a specific polymer or solvent.

Example: If t is a Thermo object, then

t.Polymers[0].phi
t.Solvents[1].mu

return the volume fraction of polymer 0 (the first polymer) and the chemical potential of solvent 1 (the second solvent).

LatticeParameters: The attribute LatticeParameter is created only by calculations for a periodic system, and is a list of values for different lattice parameters. The interpretation of the order and meaning of the lattice parameters depends on the lattice system, which is given in the input parameter file. Specific parameters can be accessed by square bracket indexing, and are float values.

Example: The expressions

t.LatticeParameters
t.LatticeParameters[0]

return the list of lattice parameters and the first lattice parameter, respectively.

Modifying properties:

The numerical values of properties stored in a Thermo object are stored as Python attributes of Thermo or Species, which can be modified as well as accessed for reading.

Example: The expressions

t.fHelmholtz *= 2
t.fHelmholtz = 0.8

reset the value of fHelmholtz.

Example: The expressions

t.Polymers[0].phi += 0.3
t.Solvents[1].mu = 0.2

modify values of phi and mu for specific species.

Example: The expressions

t.LatticeParameters = [0.2, 0.2]
t.LatticeParameters[0] = 0.2

modify lattice parameters, either by replacing the list in the first case, or by modifying a single element in the second.

Definition at line 136 of file output.py.

Constructor & Destructor Documentation

◆ __init__()

def pscfpp.output.Thermo.__init__ (   self,
  filename = None 
)

Constructor.

If the filename parameter is the name of a thermo file, the file is parsed and its contents are stored in attributes of the resulting Thermo object. If filename is absent or None, then an empty object is created.

Parameters
filenamea filename string, defult to be None.

Definition at line 148 of file output.py.

References pscfpp.output.Thermo.cellParams, pscfpp.output.Thermo.fExt, pscfpp.output.Thermo.fHelmholtz, Pscf::Fd1d::System.fHelmholtz(), Pscf::Homogeneous::Mixture.fHelmholtz(), Pscf::Pspc::System< D >.fHelmholtz(), Pscf::Pspg::System< D >.fHelmholtz(), Pscf::Interaction.fHelmholtz(), pscfpp.output.Thermo.fIdeal, pscfpp.output.Thermo.fInter, pscfpp.output.Thermo.polymers, pscfpp.output.Thermo.pressure, Pscf::Fd1d::System.pressure(), Pscf::Homogeneous::Mixture.pressure(), Pscf::Pspc::System< D >.pressure(), Pscf::Pspg::System< D >.pressure(), Pscf::Pspc::BasisFieldState< D >.read(), Pscf::Pspg::BasisFieldState< D >.read(), pscfpp.output.Thermo.read(), pscfpp.param.Composite.read(), pscfpp.param.Array.read(), pscfpp.param.Matrix.read(), pscfpp.command.Script.read(), pscfpp.field.Field.read(), Util::Label.read(), Pscf::Fd1d::Mixture.read(), Pscf::AmIteratorTmpl< Iterator< D >, FieldCUDA >.read(), Pscf::AmIteratorTmpl< Iterator, DArray< double > >.read(), Pscf::AmIteratorTmpl< Iterator, T >.read(), Pscf::AmIteratorTmpl< Iterator< D >, DArray< double > >.read(), Pscf::Pspc::Domain< D >.read(), Pscf::Pspc::FilmIteratorBase< 3, IteratorType >.read(), Pscf::Pspc::FilmIteratorBase< 1, IteratorType >.read(), Pscf::Pspc::FilmIteratorBase< 2, IteratorType >.read(), Pscf::Pspc::FilmIteratorBase< D, IteratorType >.read(), Pscf::Pspc::Mixture< D >.read(), Pscf::Pspg::Mixture< D >.read(), Util::ParamComposite.read(), pscfpp.output.Thermo.solvents, and pscfpp.output.Thermo.tableLabel.

Member Function Documentation

◆ read()

def pscfpp.output.Thermo.read (   self,
  file 
)

◆ skipEmptyLine()

def pscfpp.output.Thermo.skipEmptyLine (   self,
  file 
)

Skip empty lines in the file.

This function skips empty lines read from the file. It is a helper function used by the read() function.

Parameters
filea file object, open for reading

Definition at line 235 of file output.py.

Referenced by pscfpp.output.Thermo.read().

◆ write()

def pscfpp.output.Thermo.write (   self,
  filename 
)

Write the contents of this object in thermo file format to a file.

This function writes out the thermo file string to the specified file with the name of the passed-in parameter, filename.

Parameters
filenamea filename string.

Definition at line 250 of file output.py.

References pscfpp.command.Script.__str__(), pscfpp.field.Field.__str__(), pscfpp.file.File.__str__(), pscfpp.file.Directory.__str__(), pscfpp.make.MakeMaker.__str__(), pscfpp.output.Thermo.__str__(), pscfpp.output.State.__str__(), pscfpp.param.Composite.__str__(), pscfpp.param.Parameter.__str__(), pscfpp.param.Array.__str__(), pscfpp.param.Matrix.__str__(), pscfpp.text.Wrapper.__str__(), and pscfpp.text.Record.__str__().

◆ __str__()

def pscfpp.output.Thermo.__str__ (   self)

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