FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 31e2da19 authored by Mark Driver's avatar Mark Driver
Browse files

doc update.

parent b1acdfa1
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,14 @@ LOGGER.setLevel(logging.WARN) ...@@ -35,6 +35,14 @@ LOGGER.setLevel(logging.WARN)
def main(): def main():
"""Main function run when program called.
Returns
-------
None
Process result.
"""
# Create parser # Create parser
parser = create_phasecalculator_argparser() parser = create_phasecalculator_argparser()
# parse args # parse args
...@@ -42,14 +50,51 @@ def main(): ...@@ -42,14 +50,51 @@ def main():
return process_args(args) return process_args(args)
def process_args(args): def process_args(args):
"""Process CLI Arguments.
Parameters
----------
args : argparse.Namespace
Arguments from reading command line.
Returns
-------
None
Process result.
"""
return args.func(args) return args.func(args)
def process_inputgen(args): def process_inputgen(args):
"""Process arguments to run input file creation for phase calculation.
Parameters
----------
args : argparse.Namespace
Arguments from reading command line.
Returns
-------
None.
"""
output_filename = args.filename output_filename = args.filename
system_collection = create_system_collection(args) system_collection = create_system_collection(args)
sysproc.write_system_collection_file(system_collection, output_filename) sysproc.write_system_collection_file(system_collection, output_filename)
def process_phasecalculator(args): def process_phasecalculator(args):
"""Process arguments to run phase calculation.
Parameters
----------
args : argparse.Namespace
Arguments from reading command line.
Returns
-------
None.
"""
xml_filename = args.file xml_filename = args.file
system_collection = read_calculator_xml(xml_filename) system_collection = read_calculator_xml(xml_filename)
if args.memreq is not None: if args.memreq is not None:
...@@ -58,6 +103,19 @@ def process_phasecalculator(args): ...@@ -58,6 +103,19 @@ def process_phasecalculator(args):
run_system_collection(system_collection) run_system_collection(system_collection)
def create_system_collection(args): def create_system_collection(args):
"""Create SystemCollection from input arguments
Parameters
----------
args : argparse.Namespace
Arguments from argparse read of command line input.
Returns
-------
SystemCollection
SystemCollection.
"""
phases = read_phasecsv(args.phases) phases = read_phasecsv(args.phases)
jar_path = args.jar jar_path = args.jar
scratch_dir = args.scratch scratch_dir = args.scratch
...@@ -72,22 +130,105 @@ def create_system_collection(args): ...@@ -72,22 +130,105 @@ def create_system_collection(args):
return SystemCollection([system]) return SystemCollection([system])
def create_output_inf(fgip_output, similarity_output, similarity_output_type, vle_output): def create_output_inf(fgip_output, similarity_output, similarity_output_type, vle_output):
"""Create OutputInformation
Parameters
----------
fgip_output : bool
FGIP output result.
similarity_output : bool
Similarity output result.
similarity_output_type : str
Output type, see schema for restriction.
vle_output : bool
VLE output result.
Returns
-------
OutputInformation
Output information for calculation.
"""
return OutputInformation(fgip_output, similarity_output, similarity_output_type, vle_output) return OutputInformation(fgip_output, similarity_output, similarity_output_type, vle_output)
def create_runtime_inf(jar_path, scratch_dir, output_dir): def create_runtime_inf(jar_path, scratch_dir, output_dir):
"""Create RuntimeInformation
Parameters
----------
jar_path : str
Jar file location.
scratch_dir : str
Scratch directory path.
output_dir : str
Output directory path.
Returns
-------
RuntimeInformation
Runtime information for calculation.
"""
return RuntimeInformation(jar_path, scratch_dir, output_dir) return RuntimeInformation(jar_path, scratch_dir, output_dir)
def read_calculator_xml(xml_filename): def read_calculator_xml(xml_filename):
"""Read SystemCollection XML.
Parameters
----------
xml_filename : str
filename for SystemCollection XML.
Returns
-------
SystemCollection
System collection for calculations to run.
"""
return sysproc.read_system_collection_file(xml_filename) return sysproc.read_system_collection_file(xml_filename)
def read_phasecsv(csv_filename): def read_phasecsv(csv_filename):
"""Read CSV file containing phase infomration and create Phases object.
Parameters
----------
csv_filename : str
phase information CSV file.
Returns
-------
Phases
Phases representation of information.
"""
return csvconv.convert_csv_file_to_phases(csv_filename) return csvconv.convert_csv_file_to_phases(csv_filename)
def run_system_collection(system_collection, **kwargs): def run_system_collection(system_collection, **kwargs):
"""Run all systems in collection.
Parameters
----------
system_collection : SystemCollection
system collection.
memory_req : str, optional
Memory settings for jar executable. The default is None.
Returns
-------
None.
"""
for system_info in system_collection.system_list: for system_info in system_collection.system_list:
phasecrun.run_all_analysis(system_info, **kwargs) phasecrun.run_all_analysis(system_info, **kwargs)
def create_phasecalculator_argparser(): def create_phasecalculator_argparser():
"""Create Argument parser for Phasecalculator module.
Returns
-------
ArgumentParser
"""
description = """Phase Calculator provides methods to perform FGIP, description = """Phase Calculator provides methods to perform FGIP,
similarity and VLE analysis for solvents.""" similarity and VLE analysis for solvents."""
epilog = """Example usage""" epilog = """Example usage"""
...@@ -96,19 +237,18 @@ similarity and VLE analysis for solvents.""" ...@@ -96,19 +237,18 @@ similarity and VLE analysis for solvents."""
conflict_handler='resolve', conflict_handler='resolve',
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
subparsers = phase_argparser.add_subparsers(title="commands", dest="command") subparsers = phase_argparser.add_subparsers(title="commands", dest="command")
calc_description = """Calculation runner based on input System XML.""" calc_description = """Calculation runner based on input System XML."""
calc_epilog = """""" calc_epilog = """"""
calc_argparser = subparsers.add_parser("calculate", description=calc_description, calc_argparser = subparsers.add_parser("calculate", description=calc_description,
epilog=calc_epilog, epilog=calc_epilog,
help="calculate phase properties.", help="calculate phase properties.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
calc_argparser.add_argument("-i", "-f","--file", type=str, required=True, calc_argparser.add_argument("-i", "-f","--file", type=str, required=True,
help="") help="filename for SystemCollectionXML")
calc_argparser.add_argument("--memreq", type=str, default=None, calc_argparser.add_argument("--memreq", type=str, default=None,
help="") help="memory specifier for jar call. Defaults to system default.")
calc_argparser.set_defaults(func=process_phasecalculator) calc_argparser.set_defaults(func=process_phasecalculator)
inpgen_description = """Input SystemCollection XML generation.""" inpgen_description = """Input SystemCollection XML generation."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment