FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
phasecalculator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yusuf Hamied Department of Chemistry
Hunter Group
SSIPtools
SSIMPLEapps
phasecalculator
Commits
2fef21dc
Commit
2fef21dc
authored
5 years ago
by
Mark Driver
Browse files
Options
Downloads
Patches
Plain Diff
update to add CLI.
parent
8dcae4d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
phasecalculator/__main__.py
+26
-0
26 additions, 0 deletions
phasecalculator/__main__.py
phasecalculator/phasecalculatorcli.py
+99
-10
99 additions, 10 deletions
phasecalculator/phasecalculatorcli.py
with
125 additions
and
10 deletions
phasecalculator/__main__.py
+
26
−
0
View file @
2fef21dc
# -*- coding: utf-8 -*-
# phasecalculator calculates FGIPs, solvent similarity and VLE with SSIMPLE.
# Copyright (C) 2019 Mark D. Driver
#
# phasecalculator is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
Main script to be called for module level operation.
@author: Mark
"""
from
phasecalculator.phasecalculatorcli
import
main
if
__name__
==
'
__main__
'
:
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
phasecalculator/phasecalculatorcli.py
+
99
−
10
View file @
2fef21dc
...
@@ -22,7 +22,12 @@ Script with CLI for phasecalculator.
...
@@ -22,7 +22,12 @@ Script with CLI for phasecalculator.
import
logging
import
logging
import
argparse
import
argparse
import
phasecalculator.runners.phasecalculatorrunner
as
phasecrun
import
phasecalculator.io.systemcollectionprocessor
as
sysproc
import
phasecalculator.io.phasecsvconverter
as
csvconv
from
phasecalculator.classes.runtimeinformation
import
RuntimeInformation
from
phasecalculator.classes.outputinformation
import
OutputInformation
from
phasecalculator.classes.system
import
System
,
SystemCollection
logging
.
basicConfig
()
logging
.
basicConfig
()
LOGGER
=
logging
.
getLogger
(
__name__
)
LOGGER
=
logging
.
getLogger
(
__name__
)
...
@@ -30,22 +35,106 @@ LOGGER.setLevel(logging.WARN)
...
@@ -30,22 +35,106 @@ LOGGER.setLevel(logging.WARN)
def
main
():
def
main
():
# Create parser
# Create parser
parser
=
create_argparser
()
parser
=
create_
phasecalculator_
argparser
()
# parse args
# parse args
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
return
process_args
(
args
)
return
process_args
(
args
)
def
process_args
():
def
process_args
(
args
):
return
args
.
func
(
args
)
def
process_inputgen
(
args
):
output_filename
=
args
.
filename
system_collection
=
create_system_collection
(
args
)
sysproc
.
write_system_collection_file
(
system_collection
,
output_filename
)
def
process_phasecalculator
(
args
):
xml_filename
=
args
.
file
system_collection
=
read_calculator_xml
(
xml_filename
)
if
args
.
memreq
is
not
None
:
run_system_collection
(
system_collection
,
memory_req
=
args
.
memreq
)
else
:
run_system_collection
(
system_collection
)
def
create_system_collection
(
args
):
phases
=
read_phasecsv
(
args
.
phases
)
jar_path
=
args
.
jar
scratch_dir
=
args
.
scratch
output_dir
=
args
.
out_dir
run_inf
=
create_runtime_inf
(
jar_path
,
scratch_dir
,
output_dir
)
fgip_output
=
args
.
fgip
similarity_output
=
args
.
sim
similarity_output_type
=
args
.
sim_type
if
similarity_output
else
None
vle_output
=
args
.
vle
out_inf
=
create_output_inf
(
fgip_output
,
similarity_output
,
similarity_output_type
,
vle_output
)
system
=
System
(
phases
,
run_inf
,
out_inf
)
return
SystemCollection
([
system
])
def
create_output_inf
(
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
):
return
RuntimeInformation
(
jar_path
,
scratch_dir
,
output_dir
)
def
create_calculator_xml
():
def
read_calculator_xml
(
xml_filename
):
return
sysproc
.
read_system_collection_file
(
xml_filename
)
def
read_phasecsv
(
csv_filename
):
return
csvconv
.
convert_csv_file_to_phases
(
csv_filename
)
def
run_system_collection
(
system_collection
,
**
kwargs
):
for
system_info
in
system_collection
.
system_list
:
phasecrun
.
run_all_analysis
(
system_info
,
**
kwargs
)
def
create_phasecalculator_argparser
():
description
=
"""
Phase Calculator provides methods to perform FGIP,
similarity and VLE analysis for solvents.
"""
epilog
=
"""
Example usage
"""
phase_argparser
=
argparse
.
ArgumentParser
(
description
=
description
,
epilog
=
epilog
,
conflict_handler
=
'
resolve
'
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
subparsers
=
phase_argparser
.
add_subparsers
(
title
=
"
commands
"
,
dest
=
"
command
"
)
def
read_calculator_xml
():
def
run_system_collection
():
calc_description
=
"""
Calculation runner based on input System XML.
"""
calc_epilog
=
""""""
def
create_phasecalculator_argparser
():
calc_argparser
=
subparsers
.
add_parser
(
"
calculate
"
,
description
=
calc_description
,
epilog
=
calc_epilog
,
help
=
"
calculate phase properties.
"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
calc_argparser
.
add_argument
(
"
-i
"
,
"
-f
"
,
"
--file
"
,
type
=
str
,
required
=
True
,
help
=
""
)
calc_argparser
.
add_argument
(
"
--memreq
"
,
type
=
str
,
default
=
None
,
help
=
""
)
calc_argparser
.
set_defaults
(
func
=
process_phasecalculator
)
inpgen_description
=
"""
Input SystemCollection XML generation.
"""
inpgen_epilog
=
""""""
def
create_calculate_argparser
():
inpgen_argparser
=
subparsers
.
add_parser
(
"
inpgen
"
,
description
=
inpgen_description
,
epilog
=
inpgen_epilog
,
help
=
"
create system input xml.
"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
inpgen_argparser
.
add_argument
(
"
-p
"
,
"
--phases
"
,
type
=
str
,
help
=
""
)
inpgen_argparser
.
add_argument
(
"
-j
"
,
"
--jar
"
,
type
=
str
,
required
=
True
,
help
=
"
Phasetransfer jar path.
"
)
inpgen_argparser
.
add_argument
(
"
-x
"
,
"
--scratch
"
,
type
=
str
,
default
=
"
scratch
"
,
help
=
"
scratch directory path.
"
)
inpgen_argparser
.
add_argument
(
"
-o
"
,
"
--out_dir
"
,
type
=
str
,
default
=
"
output
"
,
help
=
"
output directory for calculation results
"
)
def
create_inputgen_argparser
():
inpgen_argparser
.
add_argument
(
"
-f
"
,
"
--fgip
"
,
action
=
'
store_true
'
,
\ No newline at end of file
help
=
"
Calculate FGIPs for input solvents
"
)
inpgen_argparser
.
add_argument
(
"
-s
"
,
"
--sim
"
,
action
=
'
store_true
'
,
help
=
"
Calculate similarity for input solvents
"
)
inpgen_argparser
.
add_argument
(
"
--sim_type
"
,
type
=
str
,
default
=
"
all
"
,
help
=
"
similarity output type.
"
)
inpgen_argparser
.
add_argument
(
"
-v
"
,
"
--vle
"
,
action
=
'
store_true
'
,
help
=
"
Calculate VLE for input solvents
"
)
inpgen_argparser
.
add_argument
(
"
--filename
"
,
type
=
str
,
default
=
"
systemcollection.xml
"
)
inpgen_argparser
.
set_defaults
(
func
=
process_inputgen
)
return
phase_argparser
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment