From ad0c32d0d833daeb86093d8229e5de9a3594c0d0 Mon Sep 17 00:00:00 2001 From: martinachondo Date: Sun, 2 Jun 2024 22:47:45 -0400 Subject: [PATCH] Run Simulation Function --- xppbe/Model/pbj_utils/pbj_interface.py | 2 +- xppbe/Scripts | 13 +++---------- xppbe/__init__.py | 9 +++++++++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/xppbe/Model/pbj_utils/pbj_interface.py b/xppbe/Model/pbj_utils/pbj_interface.py index 0162424..2483de0 100644 --- a/xppbe/Model/pbj_utils/pbj_interface.py +++ b/xppbe/Model/pbj_utils/pbj_interface.py @@ -33,4 +33,4 @@ def calculate_potential_ens(self, atom_name = ["H"], mesh_dx = 1.0, mesh_length def calculate_solvation_energy(self): self.simulation.calculate_solvation_energy() - return self.simulation.solutes[0].results['solvation_energy'] + return self.simulation.solutes[0].results['electrostatic_solvation_energy'] diff --git a/xppbe/Scripts b/xppbe/Scripts index 97da156..0b8f95d 100644 --- a/xppbe/Scripts +++ b/xppbe/Scripts @@ -18,21 +18,15 @@ function Allrun() { fi PYTHON_CODE=" -import os -import sys -from xppbe import Simulation +import os,sys +from xppbe import RunSimulation yaml_path = os.path.abspath(sys.argv[1]) - results_path = '${results_path%/results}' plot_pbj = '--pbj' in sys.argv plot_mesh = '--mesh' in sys.argv -sim = Simulation(yaml_path, results_path=results_path) -sim.create_simulation() -sim.adapt_model() -sim.solve_model() -sim.postprocessing(mesh=plot_mesh, pbj=plot_pbj) +RunSimulation(yaml_path,results_path,(plot_mesh,plot_pbj)) " sims_count=0 @@ -130,7 +124,6 @@ function SimsStatus() { if [[ "$current_dir" == "$main_dir" ]]; then sims_path="$main_dir/simulations_list" results_path="$main_dir/results" - pbj_flag='--pbj' fi for arg in "$@"; do diff --git a/xppbe/__init__.py b/xppbe/__init__.py index 31a87bd..0bee5fb 100644 --- a/xppbe/__init__.py +++ b/xppbe/__init__.py @@ -5,6 +5,15 @@ xppbe_path = os.path.dirname(os.path.abspath(__file__)) scripts_path = os.path.join(xppbe_path,'Scripts') + +def RunSimulation(yaml_path,results_path,plot_flags): + plot_mesh,plot_pbj = plot_flags + sim = Simulation(yaml_path, results_path=results_path) + sim.create_simulation() + sim.adapt_model() + sim.solve_model() + sim.postprocessing(mesh=plot_mesh, pbj=plot_pbj) + def Allrun(sims_path, results_path, plot_mesh=False, plot_pbj=False): sims_path = os.path.abspath(sims_path) results_path = os.path.abspath(results_path)