FAQ | This is a LIVE service | Changelog

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

add methods to run processing of VLE output.

parent 6a29275e
No related branches found
No related tags found
No related merge requests found
......@@ -21,12 +21,60 @@ Script for running VLE analysis.
"""
import logging
import phasecalculator.analysis.vleanalysis as vleanalysis
import phasecalculator.runners.phasetransferrunner as phaserun
logging.basicConfig()
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.WARN)
def calculate_and_process_vle_data(jar_path, phase_filename, phase_output_filename, csv_filename, **kwargs):
"""Calculate and process VLE data.
Parameters
----------
jar_path : str
Path to jar executable.
phase_filename : str
Filename for phase XML.
phase_output_filename : str
Output filename for result output.
csv_filename : str
CSV filename for output information.
memory_req : str, optional
Memory settings for jar executable. The default is None.
Raises
------
FileNotFoundError
If jar file is not found.
Returns
-------
None.
"""
run_vle_calculation(jar_path, phase_filename, phase_output_filename, **kwargs)
process_vle_data(phase_output_filename, csv_filename)
def process_vle_data(calculated_phase_filename, csv_filename):
"""Process phase XML and write to csv file.
Parameters
----------
phase_filename : str
Phase XML filename.
csv_filename : str
CSV filename for output information.
Returns
-------
None.
"""
return vleanalysis.process_vle_data(calculated_phase_filename, csv_filename)
def run_vle_calculation(jar_path, phase_filename, output_filename, **kwargs):
"""Run VLE phase calculation.
......
solvent_id temperature phase type concentrations[name, value]
1-butanol0.165water0.835298.000KELVIN 298.0 GAS LRHPLDYGYMQRHN-UHFFFAOYSA-N 0.0000021914 XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.0008190888
1-butanol0.165water0.835298.000KELVIN 298.0 CONDENSED LRHPLDYGYMQRHN-UHFFFAOYSA-N 4.4440094829 XLYOFNOQVPJJNP-UHFFFAOYSA-N 30.7036536932
......@@ -61,11 +61,16 @@ class VLEAnalysisRunnerTestCase(unittest.TestCase):
.as_posix()
)
self.phase_output_filename = (
(self.parent_directory / "resources" / "expected_phaseout.xml")
(self.parent_directory / "resources" / "expected_phasecalculated.xml")
.absolute()
.as_posix()
)
self.expected_phas_csv = (
(self.parent_directory / "resources" / "expected_phasesummary.csv")
.absolute()
.as_posix()
)
self.output_file = "phase_summary.csv"
def tearDown(self):
"""Clean up after tests.
......@@ -74,7 +79,39 @@ class VLEAnalysisRunnerTestCase(unittest.TestCase):
None.
"""
if os.path.isfile(self.output_file):
os.remove(self.output_file)
def test_calculate_and_process_vle_data(self):
"""Test expected output produced.
Returns
-------
None.
"""
vlerun.calculate_and_process_vle_data(self.example_jar,
self.phase_filename,
self.phase_output_filename,
self.output_file)
with open(self.output_file, "r") as act_file:
actual_contents = act_file.read()
with open(self.expected_phas_csv, "r") as exp_file:
expected_contents = exp_file.read()
self.assertMultiLineEqual(expected_contents, actual_contents)
def test_process_vle_data(self):
"""Test expected output produced.
Returns
-------
None.
"""
vlerun.process_vle_data(self.phase_output_filename, self.output_file)
with open(self.output_file, "r") as act_file:
actual_contents = act_file.read()
with open(self.expected_phas_csv, "r") as exp_file:
expected_contents = exp_file.read()
self.assertMultiLineEqual(expected_contents, actual_contents)
def test_run_vle_calculation(self):
"""Test expected system call is made.
......
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