From 13e43e13d3bbd5af4377ff72c210dcd84a31260d Mon Sep 17 00:00:00 2001 From: Brad Crawford <65550266+bc118@users.noreply.github.com> Date: Tue, 16 Jul 2024 19:56:34 -0400 Subject: [PATCH 1/9] 'symengine.sympify' changed to 'sympy.nsimplify' to solve for non-integers Although,'symengine.sympify' from 'import symengine ' is faster, it was changed to 'sympy.nsimplify' as it changes - improves the solving of the code by also solving 0.5 or other non-integers with integers. --- mosdef_gomc/utils/gmso_equation_compare.py | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mosdef_gomc/utils/gmso_equation_compare.py b/mosdef_gomc/utils/gmso_equation_compare.py index 00fa86b5..aa84a403 100644 --- a/mosdef_gomc/utils/gmso_equation_compare.py +++ b/mosdef_gomc/utils/gmso_equation_compare.py @@ -4,10 +4,11 @@ # import signac import xml.etree.ElementTree as ET -import symengine import sympy import unyt as u +# Although,'symengine.sympify' from 'import symengine ' is faster, it was changed to 'sympy.nsimplify' as it changes +# improves the solving of the code by also solving 0.5 or other non-integers with integers. # compare Lennard-Jones (LJ) non-bonded equations def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): @@ -44,8 +45,8 @@ def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_lj_form) - / symengine.sympify(base_lj_form), + - sympy.nsimplify(new_lj_form) + / sympy.nsimplify(base_lj_form), Rmin - sigma * two ** (1 / 6), two - 2, ], @@ -96,8 +97,8 @@ def evaluate_nonbonded_mie_format_with_scaler(new_mie_form, base_mie_form): values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_mie_form) - / symengine.sympify(base_mie_form), + - sympy.nsimplify(new_mie_form) + / sympy.nsimplify(base_mie_form), ], [eqn_ratio], ) @@ -147,8 +148,8 @@ def evaluate_nonbonded_exp6_format_with_scaler(new_exp6_form, base_exp6_form): values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_exp6_form) - / symengine.sympify(base_exp6_form), + - sympy.nsimplify(new_exp6_form) + / sympy.nsimplify(base_exp6_form), ], [eqn_ratio], ) @@ -413,8 +414,8 @@ def evaluate_harmonic_angle_format_with_scaler(new_angle_form, base_angle_form): values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_angle_form) - / symengine.sympify(base_angle_form), + - sympy.nsimplify(new_angle_form) + / sympy.nsimplify(base_angle_form), ], [eqn_ratio], ) @@ -460,8 +461,8 @@ def evaluate_harmonic_torsion_format_with_scaler( values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_torsion_form) - / symengine.sympify(base_torsion_form), + - sympy.nsimplify(new_torsion_form) + / sympy.nsimplify(base_torsion_form), ], [eqn_ratio], ) @@ -509,8 +510,8 @@ def evaluate_OPLS_torsion_format_with_scaler( values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_torsion_form) - / symengine.sympify(base_torsion_form), + - sympy.nsimplify(new_torsion_form) + / sympy.nsimplify(base_torsion_form), ], [eqn_ratio], ) From cc642381e2bf1d4785ff787292155e6024785a85 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 23:59:40 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mosdef_gomc/utils/gmso_equation_compare.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mosdef_gomc/utils/gmso_equation_compare.py b/mosdef_gomc/utils/gmso_equation_compare.py index aa84a403..2417ca76 100644 --- a/mosdef_gomc/utils/gmso_equation_compare.py +++ b/mosdef_gomc/utils/gmso_equation_compare.py @@ -10,6 +10,7 @@ # Although,'symengine.sympify' from 'import symengine ' is faster, it was changed to 'sympy.nsimplify' as it changes # improves the solving of the code by also solving 0.5 or other non-integers with integers. + # compare Lennard-Jones (LJ) non-bonded equations def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): """Compare a new Lennard-Jones (LJ) form to a base LJ form (new LJ form / base LJ form). @@ -45,8 +46,7 @@ def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_lj_form) - / sympy.nsimplify(base_lj_form), + - sympy.nsimplify(new_lj_form) / sympy.nsimplify(base_lj_form), Rmin - sigma * two ** (1 / 6), two - 2, ], From d1058bb67ef7f2ea47c052b2b4ea68c4fe1997c5 Mon Sep 17 00:00:00 2001 From: Brad Crawford <65550266+bc118@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:03:00 -0400 Subject: [PATCH 3/9] Update gmso_equation_compare.py changed some other 'symengine.symplify' to 'sympy.nsimplify' --- mosdef_gomc/utils/gmso_equation_compare.py | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mosdef_gomc/utils/gmso_equation_compare.py b/mosdef_gomc/utils/gmso_equation_compare.py index 2417ca76..98030354 100644 --- a/mosdef_gomc/utils/gmso_equation_compare.py +++ b/mosdef_gomc/utils/gmso_equation_compare.py @@ -46,7 +46,8 @@ def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_lj_form) / sympy.nsimplify(base_lj_form), + - sympy.nsimplify(new_lj_form) + / sympy.nsimplify(base_lj_form), Rmin - sigma * two ** (1 / 6), two - 2, ], @@ -367,8 +368,8 @@ def evaluate_harmonic_bond_format_with_scaler(new_bond_form, base_bond_form): values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_bond_form) - / symengine.sympify(base_bond_form), + - sympy.nsimplify(new_bond_form) + / sympy.nsimplify(base_bond_form), ], [eqn_ratio], ) @@ -557,8 +558,8 @@ def evaluate_periodic_torsion_format_with_scaler( values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_torsion_form) - / symengine.sympify(base_torsion_form), + - sympy.nsimplify(new_torsion_form) + / sympy.nsimplify(base_torsion_form), ], [eqn_ratio], ) @@ -604,8 +605,8 @@ def evaluate_RB_torsion_format_with_scaler(new_torsion_form, base_torsion_form): values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_torsion_form) - / symengine.sympify(base_torsion_form), + - sympy.nsimplify(new_torsion_form) + / sympy.nsimplify(base_torsion_form), ], [eqn_ratio], ) @@ -651,8 +652,8 @@ def evaluate_harmonic_improper_format_with_scaler( values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_improper_form) - / symengine.sympify(base_improper_form), + - sympy.nsimplify(new_improper_form) + / sympy.nsimplify(base_improper_form), ], [eqn_ratio], ) @@ -698,8 +699,8 @@ def evaluate_periodic_improper_format_with_scaler( values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_improper_form) - / symengine.sympify(base_improper_form), + - sympy.nsimplify(new_improper_form) + / sympy.nsimplify(base_improper_form), ], [eqn_ratio], ) From b40b73733de1e80ea5b45036fdb923ff2a74afb3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 00:03:37 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mosdef_gomc/utils/gmso_equation_compare.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mosdef_gomc/utils/gmso_equation_compare.py b/mosdef_gomc/utils/gmso_equation_compare.py index 98030354..2dbbb5f4 100644 --- a/mosdef_gomc/utils/gmso_equation_compare.py +++ b/mosdef_gomc/utils/gmso_equation_compare.py @@ -46,8 +46,7 @@ def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_lj_form) - / sympy.nsimplify(base_lj_form), + - sympy.nsimplify(new_lj_form) / sympy.nsimplify(base_lj_form), Rmin - sigma * two ** (1 / 6), two - 2, ], From a9685d0e9b7a49210fba7084b6c672a895559257 Mon Sep 17 00:00:00 2001 From: Brad Crawford <65550266+bc118@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:17:21 -0400 Subject: [PATCH 5/9] Update gmso_equation_compare.py Changed back to only OPLS dihedral using sympy.nsimplify as it is less efficient than symengine.sympify, and the only way to get the non-integer valuse for OPLS working --- mosdef_gomc/utils/gmso_equation_compare.py | 43 ++++++++++++---------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/mosdef_gomc/utils/gmso_equation_compare.py b/mosdef_gomc/utils/gmso_equation_compare.py index 2dbbb5f4..ff5cac6a 100644 --- a/mosdef_gomc/utils/gmso_equation_compare.py +++ b/mosdef_gomc/utils/gmso_equation_compare.py @@ -4,10 +4,12 @@ # import signac import xml.etree.ElementTree as ET +import symengine import sympy import unyt as u -# Although,'symengine.sympify' from 'import symengine ' is faster, it was changed to 'sympy.nsimplify' as it changes +# Although,'symengine.sympify' from 'import symengine ' is faster, it was changed to 'sympy.nsimplify' for some +# with the 0.5 decimals in it like as it changes # improves the solving of the code by also solving 0.5 or other non-integers with integers. @@ -46,7 +48,8 @@ def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_lj_form) / sympy.nsimplify(base_lj_form), + - symengine.sympify(new_lj_form) + / symengine.sympify(base_lj_form), Rmin - sigma * two ** (1 / 6), two - 2, ], @@ -97,8 +100,8 @@ def evaluate_nonbonded_mie_format_with_scaler(new_mie_form, base_mie_form): values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_mie_form) - / sympy.nsimplify(base_mie_form), + - symengine.sympify(new_mie_form) + / symengine.sympify(base_mie_form), ], [eqn_ratio], ) @@ -148,8 +151,8 @@ def evaluate_nonbonded_exp6_format_with_scaler(new_exp6_form, base_exp6_form): values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_exp6_form) - / sympy.nsimplify(base_exp6_form), + - symengine.sympify(new_exp6_form) + / symengine.sympify(base_exp6_form), ], [eqn_ratio], ) @@ -367,8 +370,8 @@ def evaluate_harmonic_bond_format_with_scaler(new_bond_form, base_bond_form): values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_bond_form) - / sympy.nsimplify(base_bond_form), + - symengine.sympify(new_bond_form) + / symengine.sympify(base_bond_form), ], [eqn_ratio], ) @@ -414,8 +417,8 @@ def evaluate_harmonic_angle_format_with_scaler(new_angle_form, base_angle_form): values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_angle_form) - / sympy.nsimplify(base_angle_form), + - symengine.sympify(new_angle_form) + / symengine.sympify(base_angle_form), ], [eqn_ratio], ) @@ -461,8 +464,8 @@ def evaluate_harmonic_torsion_format_with_scaler( values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_torsion_form) - / sympy.nsimplify(base_torsion_form), + - symengine.sympify(new_torsion_form) + / symengine.sympify(base_torsion_form), ], [eqn_ratio], ) @@ -557,8 +560,8 @@ def evaluate_periodic_torsion_format_with_scaler( values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_torsion_form) - / sympy.nsimplify(base_torsion_form), + - symengine.sympify(new_torsion_form) + / symengine.sympify(base_torsion_form), ], [eqn_ratio], ) @@ -604,8 +607,8 @@ def evaluate_RB_torsion_format_with_scaler(new_torsion_form, base_torsion_form): values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_torsion_form) - / sympy.nsimplify(base_torsion_form), + - symengine.sympify(new_torsion_form) + / symengine.sympify(base_torsion_form), ], [eqn_ratio], ) @@ -651,8 +654,8 @@ def evaluate_harmonic_improper_format_with_scaler( values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_improper_form) - / sympy.nsimplify(base_improper_form), + - symengine.sympify(new_improper_form) + / symengine.sympify(base_improper_form), ], [eqn_ratio], ) @@ -698,8 +701,8 @@ def evaluate_periodic_improper_format_with_scaler( values = sympy.nonlinsolve( [ eqn_ratio - - sympy.nsimplify(new_improper_form) - / sympy.nsimplify(base_improper_form), + - symengine.sympify(new_improper_form) + / symengine.sympify(base_improper_form), ], [eqn_ratio], ) From cf6c60db1046456395c3dfdd3ba28e37ed951cb6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 00:17:43 +0000 Subject: [PATCH 6/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mosdef_gomc/utils/gmso_equation_compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mosdef_gomc/utils/gmso_equation_compare.py b/mosdef_gomc/utils/gmso_equation_compare.py index ff5cac6a..1bd6c278 100644 --- a/mosdef_gomc/utils/gmso_equation_compare.py +++ b/mosdef_gomc/utils/gmso_equation_compare.py @@ -48,7 +48,7 @@ def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_lj_form) + - symengine.sympify(new_lj_form) / symengine.sympify(base_lj_form), Rmin - sigma * two ** (1 / 6), two - 2, From 0fdfaa61fe4c7d32cf2bc1e81a37d46a18d0f80f Mon Sep 17 00:00:00 2001 From: Brad Crawford <65550266+bc118@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:18:05 -0400 Subject: [PATCH 7/9] Update gmso_equation_compare.py --- mosdef_gomc/utils/gmso_equation_compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mosdef_gomc/utils/gmso_equation_compare.py b/mosdef_gomc/utils/gmso_equation_compare.py index 1bd6c278..ff5cac6a 100644 --- a/mosdef_gomc/utils/gmso_equation_compare.py +++ b/mosdef_gomc/utils/gmso_equation_compare.py @@ -48,7 +48,7 @@ def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_lj_form) + - symengine.sympify(new_lj_form) / symengine.sympify(base_lj_form), Rmin - sigma * two ** (1 / 6), two - 2, From bf36df080bdb7de929383ed767fe3d3f05c7acf0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 00:18:16 +0000 Subject: [PATCH 8/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mosdef_gomc/utils/gmso_equation_compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mosdef_gomc/utils/gmso_equation_compare.py b/mosdef_gomc/utils/gmso_equation_compare.py index ff5cac6a..1bd6c278 100644 --- a/mosdef_gomc/utils/gmso_equation_compare.py +++ b/mosdef_gomc/utils/gmso_equation_compare.py @@ -48,7 +48,7 @@ def evaluate_nonbonded_lj_format_with_scaler(new_lj_form, base_lj_form): values = sympy.nonlinsolve( [ eqn_ratio - - symengine.sympify(new_lj_form) + - symengine.sympify(new_lj_form) / symengine.sympify(base_lj_form), Rmin - sigma * two ** (1 / 6), two - 2, From 8cff93a7693813d82321e2e91a771a5be665b5c1 Mon Sep 17 00:00:00 2001 From: Brad Crawford <65550266+bc118@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:21:43 -0400 Subject: [PATCH 9/9] Update gmso_equation_compare.py --- mosdef_gomc/utils/gmso_equation_compare.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mosdef_gomc/utils/gmso_equation_compare.py b/mosdef_gomc/utils/gmso_equation_compare.py index 1bd6c278..8b2495ca 100644 --- a/mosdef_gomc/utils/gmso_equation_compare.py +++ b/mosdef_gomc/utils/gmso_equation_compare.py @@ -9,8 +9,8 @@ import unyt as u # Although,'symengine.sympify' from 'import symengine ' is faster, it was changed to 'sympy.nsimplify' for some -# with the 0.5 decimals in it like as it changes -# improves the solving of the code by also solving 0.5 or other non-integers with integers. +# less simple equations with the 0.5 decimals in it (example OPLS dihedral). This was the only was to improve +# or actually solve for the scalers in the equations when using non-integers in the forms like the OPLS dihedral. # compare Lennard-Jones (LJ) non-bonded equations