PDielec.Utilities¶
Utility Functions.
A set of utility functions that may be used anywhere in the package.
Classes¶
A class aimed at providing a structured way to include debug messages in code. |
Functions¶
|
Determine the simulation program from a given filename. |
|
Get the appropriate output reader based on the simulation program and, if specified, the quantum mechanical program. |
|
Print 4x4 matrices or 4 vectors. |
Module Contents¶
- class PDielec.Utilities.Debug(debug, text, level=0)[source]¶
A class aimed at providing a structured way to include debug messages in code.
Methods¶
- print(args, level=0)
Prints debug messages based on the debug level provided as argument compared to the object’s debug level.
- state()
Returns the current state (enabled or disabled) of debugging.
Notes¶
The print method provides a flexible way to include additional information along with the base debug message, allowing for a detailed and adjustable debugging output.
- print(*args, level=0)[source]¶
Print message if debugging level allows.
Parameters¶
- args
Variable length argument list for the message to be printed.
- levelint, optional
The level of the message that determines if it gets printed or not, based on the instance’s level. Default value is 0.
Notes¶
This method will only print the message if the instance’s debug flag is True and the provided level is less than or equal to the instance’s level.
- debug¶
- level = 0¶
- text¶
- PDielec.Utilities.find_program_from_name(filename)[source]¶
Determine the simulation program from a given filename.
Parameters¶
- filenamestr
The complete path (absolute or relative) to a file.
Returns¶
- str
The program name that was used to calculate the frequencies.
Notes¶
This function examines the file extension and, in some cases, the presence of specific files in the same directory, to determine the associated simulation program. It recognizes files from several popular materials simulation programs, such as ‘phonopy’, ‘gulp’, ‘vasp’, and others.
Examples¶
program = find_program_from_name('./data/structure.castep') print(program) # Output: "castep" program = find_program_from_name('path/to/simulation/phonopy.yaml') print(program) # Output: "phonopy"
- PDielec.Utilities.get_reader(name, program, debug=False)[source]¶
Get the appropriate output reader based on the simulation program and, if specified, the quantum mechanical program.
This function is designed to create an output reader object for various simulation programs (like CASTEP, VASP, etc.) and, for phonopy simulations, it can additionally create a quantum mechanical output reader based on the specified quantum mechanical program.
Parameters¶
- namestr
The primary filepath or name associated with the output file(s).
- programstr
The name of the simulation program. Supported values are ‘castep’, ‘vasp’, ‘gulp’, ‘crystal’, ‘abinit’, ‘qe’, and ‘phonopy’.
- debugboolean
Optional. If true print debug information. Default is false
Returns¶
- object
An instance of the appropriate output reader class based on the input program
Examples¶
>>> reader = get_reader("output.log", "castep") >>> reader = get_reader("output", "phonopy")