FAQ | This is a LIVE service | Changelog

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

update class methods and addition of new ones to make calculations easier.

parent d1ad14cd
No related branches found
No related tags found
No related merge requests found
......@@ -107,6 +107,22 @@ class Phases(object):
else:
phase_dict[phase.temperature] = [phase]
return phase_dict
def get_phase_molefractions_by_temperature(self):
"""Get molefraction dictionaries for all phases in collection grouped by temperature.
Returns
-------
phase_dict : dict
Temperature: list of phase molefraction data pairs.
"""
phase_dict = {}
for phase in self.phase_list:
if phase.temperature in phase_dict.keys():
phase_dict[phase.temperature].append(phase.get_molefractions_by_molecule())
else:
phase_dict[phase.temperature] = [phase.get_molefractions_by_molecule()]
return phase_dict
def get_molefractions_by_molecule_list(self):
"""List of molefraction dictionaries for all phases in collection.
......
......@@ -163,7 +163,17 @@ class System(object):
Temperature: list of Phase objects pairs.
"""
return self.phases.get_phase_compositions_by_temperature()
return self.phases.get_phase_molefractions_by_temperature()
def get_molefractions_by_molecule_list(self):
"""List of molefraction dictionaries for all phases in collection.
Returns
-------
mole_fraction_dict_list : list of dict
list of phase molefraction data.
"""
return self.phases.get_molefractions_by_molecule_list()
def get_ssip_file_locations(self):
"""Get the SSIP file locations for all molecules in any phase.
......@@ -173,4 +183,34 @@ class System(object):
Set of unique SSIP file locations.
"""
return self.phases.get_ssip_file_locations()
\ No newline at end of file
return self.phases.get_ssip_file_locations()
def calc_fgip(self):
"""Boolean indicating whether to Calculate FGIP information for Phases.
Returns
-------
bool
calc FGIP.
"""
return self.output_information.fgip_output
def calc_similarity(self):
"""Boolean indicating whether to calculate similarity information for Phases.
Returns
-------
bool
calc Similarity.
"""
return self.output_information.similarity_output
def calc_vle(self):
"""Boolean indicating whether to calculate VLE information for Phases.
Returns
-------
bool
calc VLE.
"""
return self.output_information.vle_output
......@@ -96,6 +96,17 @@ class PhasesTestCase(unittest.TestCase):
expected_dict = {self.temperature: [self.phase]}
actual_dict = self.phases.get_phase_compositions_by_temperature()
self.assertDictEqual(expected_dict, actual_dict)
def test_get_phase_molefractions_by_temperature(self):
"""Test expected dictionary produced.
Returns
-------
None.
"""
expected_dict = {self.temperature: [{"water":1.0}]}
actual_dict = self.phases.get_phase_molefractions_by_temperature()
self.assertDictEqual(expected_dict, actual_dict)
def test_get_molefractions_by_molecule_list(self):
"""Test expected list is produced.
......
......@@ -160,9 +160,20 @@ class SystemTestCase(unittest.TestCase):
None.
"""
expected_dict = {self.temperature: [self.phase]}
expected_dict = {self.temperature: [{"water":1.0}]}
actual_dict = self.system.get_phase_compositions_by_temperature()
self.assertDictEqual(expected_dict, actual_dict)
def test_get_molefractions_by_molecule_list(self):
"""Test
Returns
-------
None.
"""
expected_list = [{"water":1.0}]
actual_list = self.system.get_molefractions_by_molecule_list()
self.assertListEqual(expected_list, actual_list)
def test_sys_get_ssip_file_locations(self):
"""Test expected set of file locations is returned.
......@@ -174,3 +185,30 @@ class SystemTestCase(unittest.TestCase):
expected_set = {self.molecule.ssip_file_loc}
actual_set = self.system.get_ssip_file_locations()
self.assertSetEqual(expected_set, actual_set)
def test_calc_fgip(self):
"""Test expected bool returned.
Returns
-------
None.
"""
self.assertTrue(self.system.calc_fgip())
def test_similarity(self):
"""Test expected bool returned.
Returns
-------
None.
"""
self.assertTrue(self.system.calc_similarity())
def test_vle(self):
"""Test expected bool returned.
Returns
-------
None.
"""
self.assertTrue(self.system.calc_vle())
\ No newline at end of file
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