From c902b47e8d488fbe923d8daa9d085bbb75fe5594 Mon Sep 17 00:00:00 2001 From: Felix <53275123+fcuantico@users.noreply.github.com> Date: Mon, 20 Jan 2025 13:20:20 -0600 Subject: [PATCH 01/17] __init__.py adding lenard-jones potential Adding the lenard-jones potential --- .../structurefinder/lj_potential/__init__.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/python/structurefinder/lj_potential/__init__.py b/src/python/structurefinder/lj_potential/__init__.py index a8d4745..5207ff6 100644 --- a/src/python/structurefinder/lj_potential/__init__.py +++ b/src/python/structurefinder/lj_potential/__init__.py @@ -11,3 +11,55 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np +import plugandplay as pp +from simde import TotalEnergy + +class LJ_potential(pp.ModuleBase): + # Module Construct -------------------------------------------------------- + def __init__(self): + """ + This module Evaluates the Lennard-Jones 1D potential function (E), and + calculates minus the gradient (Force) in Cartesian coordinates, + according to the relation + + FC = - dE/dx + """ + pp.ModuleBase.__init__(self) + self.description("Lennard-Jones 1D potential function") + self.satisfies_property_type(TotalEnergy()) + #-------------------------------------------------------------------------- + + # Module run_ member function --------------------------------------------- + def run_(self, inputs): + """ + Parameters + ---------- + inputs : x-coordinate, + TYPE ---> Float + + Returns + ------- + E: Lennard-Jonnes 1D potential Energy, + TYPE ---> Float + + FC: Force in cartesian coordinates evaluated at the given input, + acording to the relation + FC = - dE/dx + + TYPE ---> Float + """ + pt = TotalEnergy() + x0 = pt.unwrap_inputs(inputs) + #-------------- LENNARD-JONES FUNCTION -------------------------------- + E = lambda x: 4*((1/x**12)-(1/x**6)) + #------------- ANALYTIC FORCE ----------------------------------------- + DE_x = -24*((2/x0**13)-(1/x0**7)) + FC = -DE_x + #---------------------------------------------------------------------- + rv = self.results() + return pt.wrap_results(rv, E,FC) + #-------------------------------------------------------------------------- + +def load_Lenard_Jones_potential(mm): + mm.add_module("Lenard-Jones", LJ_potential()) From 71d01bde3857ed93ad4cf7e398a2e32f7890ff9b Mon Sep 17 00:00:00 2001 From: leothan Date: Fri, 24 Jan 2025 15:20:48 -0600 Subject: [PATCH 02/17] Change E to E(x0) and add __init__.py and change the name of the original file to lj_potential.py --- .../structurefinder/lj_potential/__init__.py | 65 ------------------- .../lj_potential/lj_potential.py | 65 +++++++++++++++++++ 2 files changed, 65 insertions(+), 65 deletions(-) create mode 100644 src/python/structurefinder/lj_potential/lj_potential.py diff --git a/src/python/structurefinder/lj_potential/__init__.py b/src/python/structurefinder/lj_potential/__init__.py index 5207ff6..e69de29 100644 --- a/src/python/structurefinder/lj_potential/__init__.py +++ b/src/python/structurefinder/lj_potential/__init__.py @@ -1,65 +0,0 @@ -# Copyright 2025 NWChemEx Community -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import numpy as np -import plugandplay as pp -from simde import TotalEnergy - -class LJ_potential(pp.ModuleBase): - # Module Construct -------------------------------------------------------- - def __init__(self): - """ - This module Evaluates the Lennard-Jones 1D potential function (E), and - calculates minus the gradient (Force) in Cartesian coordinates, - according to the relation - - FC = - dE/dx - """ - pp.ModuleBase.__init__(self) - self.description("Lennard-Jones 1D potential function") - self.satisfies_property_type(TotalEnergy()) - #-------------------------------------------------------------------------- - - # Module run_ member function --------------------------------------------- - def run_(self, inputs): - """ - Parameters - ---------- - inputs : x-coordinate, - TYPE ---> Float - - Returns - ------- - E: Lennard-Jonnes 1D potential Energy, - TYPE ---> Float - - FC: Force in cartesian coordinates evaluated at the given input, - acording to the relation - FC = - dE/dx - - TYPE ---> Float - """ - pt = TotalEnergy() - x0 = pt.unwrap_inputs(inputs) - #-------------- LENNARD-JONES FUNCTION -------------------------------- - E = lambda x: 4*((1/x**12)-(1/x**6)) - #------------- ANALYTIC FORCE ----------------------------------------- - DE_x = -24*((2/x0**13)-(1/x0**7)) - FC = -DE_x - #---------------------------------------------------------------------- - rv = self.results() - return pt.wrap_results(rv, E,FC) - #-------------------------------------------------------------------------- - -def load_Lenard_Jones_potential(mm): - mm.add_module("Lenard-Jones", LJ_potential()) diff --git a/src/python/structurefinder/lj_potential/lj_potential.py b/src/python/structurefinder/lj_potential/lj_potential.py new file mode 100644 index 0000000..ff116d4 --- /dev/null +++ b/src/python/structurefinder/lj_potential/lj_potential.py @@ -0,0 +1,65 @@ +# Copyright 2025 NWChemEx Community +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import numpy as np +import plugandplay as pp +from simde import TotalEnergy + +class LJ_potential(pp.ModuleBase): + # Module Construct -------------------------------------------------------- + def __init__(self): + """ + This module Evaluates the Lennard-Jones 1D potential function (E), and + calculates minus the gradient (Force) in Cartesian coordinates, + according to the relation + + FC = - dE/dx + """ + pp.ModuleBase.__init__(self) + self.description("Lennard-Jones 1D potential function") + self.satisfies_property_type(TotalEnergy()) + #-------------------------------------------------------------------------- + + # Module run_ member function --------------------------------------------- + def run_(self, inputs): + """ + Parameters + ---------- + inputs : x-coordinate, + TYPE ---> Float + + Returns + ------- + E: Lennard-Jonnes 1D potential Energy, + TYPE ---> Float + + FC: Force in cartesian coordinates evaluated at the given input, + acording to the relation + FC = - dE/dx + + TYPE ---> Float + """ + pt = TotalEnergy() + x0 = pt.unwrap_inputs(inputs) + #-------------- LENNARD-JONES FUNCTION -------------------------------- + E = lambda x: 4*((1/x**12)-(1/x**6)) + #------------- ANALYTIC FORCE ----------------------------------------- + DE_x = -24*((2/x0**13)-(1/x0**7)) + FC = -DE_x + #---------------------------------------------------------------------- + rv = self.results() + return pt.wrap_results(rv, E(x0),FC) + #-------------------------------------------------------------------------- + +def load_Lenard_Jones_potential(mm): + mm.add_module("Lenard-Jones", LJ_potential()) From 089d15dc512a924793a0c8303854081b81a8a096 Mon Sep 17 00:00:00 2001 From: leothan Date: Fri, 14 Feb 2025 08:33:42 -0600 Subject: [PATCH 03/17] lenard jones potential module added --- .../LJ_MD_plot.py | 80 +++++++++++++++++++ .../LJ_potential.py | 63 +++++++++++++++ .../lennard_jones_potential_module.py | 46 +++++++++++ 3 files changed, 189 insertions(+) create mode 100644 codes/modules/lennard_jones_potential_module/LJ_MD_plot.py create mode 100644 codes/modules/lennard_jones_potential_module/LJ_potential.py create mode 100644 codes/modules/lennard_jones_potential_module/lennard_jones_potential_module.py diff --git a/codes/modules/lennard_jones_potential_module/LJ_MD_plot.py b/codes/modules/lennard_jones_potential_module/LJ_MD_plot.py new file mode 100644 index 0000000..3971da4 --- /dev/null +++ b/codes/modules/lennard_jones_potential_module/LJ_MD_plot.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Wed Aug 9 10:20:29 2023 + +@author: Felix Rojas +""" + +# Imported packages: +import numpy as np +import matplotlib as mpl +from mpl_toolkits import mplot3d +import matplotlib.pyplot as plt + + +def LJ_MD_plot(points): + + # Activating latex rendering text + plt.rcParams['text.usetex'] = True + # Turn interactive plotting on + #------------- + plt.ion() # <-- To be able to close graph and keep working + #------------- on the console without the console get stuc + + # Definition of Figure and Axes + #fig, axes = plt.subplots(1,1,figsize=(12,7),subplot_kw={'projection': '3d'}) + fig,axes=plt.subplots(1,1,figsize=(12,7)) + + + + def title_and_labels(ax): + ax.set_title('BE2 Optimization', fontsize = 25) + ax.set_xlabel("$x$", fontsize=16) + ax.set_ylabel("$y$", fontsize=16) + #ax.set_zlabel("$f(x,y)$", fontsize=16) + + if len(points)<100: + x = np.linspace(0.92, 2, 500) + + else: + x = np.linspace(0.92, 5, 500) + + E = lambda x: 4*((1/x**12)-(1/x**6)) + + + + #-- Plot ---------------------------------------- + #cp = axes.plot_surface(X, Y, Z, cmap=plt.cm.YlGnBu_r) + p = axes.plot(x,E(x), color ='k', alpha=0.5) + #axes.view_init(60, -63) + #axes.view_init(45, -60) + #---- Axes configuration------------------------- + title_and_labels(axes) + #----------------------------------------------- + #--- Adding color bar to plot + #cb = fig.colorbar(cp) # Add a colorbar to a plot + #cb.set_label(r"$z$", fontsize=16) + #------------- + + + + +# x_coord = [] +# y_coord = [] + for i in points: + x = i[0] + + axes.scatter(x, E(x), c = "r", marker = '.') + #axes.scatter(x,y, marker = ".", c = "r") <--- contour points in + # in the same 3d graph projected to the xy-plnae + + if len(points)<100: + plt.xlim(0.7, 1.5) + else: + plt.xlim(0.7, 3.5) + + + + plt.savefig('NSTOVSUT_lennard-jones.png', bbox_inches='tight') + plt.show() diff --git a/codes/modules/lennard_jones_potential_module/LJ_potential.py b/codes/modules/lennard_jones_potential_module/LJ_potential.py new file mode 100644 index 0000000..9f3b562 --- /dev/null +++ b/codes/modules/lennard_jones_potential_module/LJ_potential.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Thu Aug 10 10:51:27 2023 + +@author: Felix Rojas +""" + +import numpy as np + +class Lennard_Jones_Potential(): + """ + This Class Evaluates the Spiral Potential Function, and calculates + the Force in Polar and Cartesian coordinates. T + + The object of this class will have as atributes the force values in each + coordinate system and the spiral "energy" value. + + Also as a way to check the analytical derivatives, numerical derivatives + have been calculated. + """ + + + def __init__(self,x_coordinate): + + x0 = x_coordinate + + + #-------------- LENNARD-JONES FUNCTION ---------------------------- + E = lambda x: 4*((1/x**12)-(1/x**6)) + + #----------------------------------------------------------- + + #------------- ANALYTIC FORCE ------------------------------ + + DE_x = -24*((2/x0**13)-(1/x0**7)) + FORCE_CARTESIAN = -DE_x + + #self.force_polar = FORCE_POLAR + self.force_cart = FORCE_CARTESIAN + self.LJ_energy = E(x0) + + # 3. Numerical FORCE calculation ------------------------------ + # Using Richardson Extrapolation to get O(h**4) by considering + # The central formula approximation to the derivative + # + # f'(x0) = (f(x0+h)-f(x0-h))/(2*h), O(h**2) + # -------------------------------------------------------------- + #Ec = lambda x, y: (a-x)**2 + b*(y-x**2)**2 + + #----------------------------------------------------------------- + #N1x = lambda h: (Ec(x0+h,y0) - Ec(x0-h,y0))/(2*h) + #Dx2 = (1/3)*(4*N1x(h/2)- N1x(h)) + #----------------------------------------------------------------- + #N1y = lambda h: (Ec(x0,y0+h) - Ec(x0,y0-h))/(2*h) + #Dy2 = (1/3)*(4*N1y(h/2)- N1y(h)) + #---------------------------------------------------------------- + #FORCE_NUMERICAL = -np.array([Dx2,Dy2]) + + #self.Ec = Ec(x0,y0) + #self.force_numerical = FORCE_NUMERICAL + + diff --git a/codes/modules/lennard_jones_potential_module/lennard_jones_potential_module.py b/codes/modules/lennard_jones_potential_module/lennard_jones_potential_module.py new file mode 100644 index 0000000..20770d7 --- /dev/null +++ b/codes/modules/lennard_jones_potential_module/lennard_jones_potential_module.py @@ -0,0 +1,46 @@ +""" +@author: Felix Rojas +""" + +import numpy as np +import plugandplay as pp +from simde import TotalEnergy + +class LJ_potential(pp.ModuleBase): + # Module Construct -------------------------------------------------------- + def __init__(self): + """ + This module Evaluates the Lennard-Jones 1D potential function (E) + """ + pp.ModuleBase.__init__(self) + self.description("Lennard-Jones 1D potential function") + self.satisfies_property_type(TotalEnergy()) + #-------------------------------------------------------------------------- + + # Module run_ member function --------------------------------------------- + def run_(self, inputs): + """ + Parameters + ---------- + inputs : Diatomic distance, + TYPE ---> Float + + Returns + ------- + E: Lennard-Jonnes 1D potential Energy, + TYPE ---> Float + """ + pt = TotalEnergy() + x0 = pt.unwrap_inputs(inputs) + #-------------- LENNARD-JONES FUNCTION -------------------------------- + E = lambda x: 4*((1/x**12)-(1/x**6)) + #------------- ANALYTIC FORCE ----------------------------------------- + DE_x = -24*((2/x0**13)-(1/x0**7)) + FC = -DE_x + #---------------------------------------------------------------------- + rv = self.results() + return pt.wrap_results(rv, E(x0)) + #-------------------------------------------------------------------------- + +def load_Lenard_Jones_potential(mm): + mm.add_module("Lenard-Jones", LJ_potential()) \ No newline at end of file From a0ad0a08157ab68750d383733dfc3134880857f7 Mon Sep 17 00:00:00 2001 From: leothan Date: Wed, 26 Feb 2025 18:21:43 -0600 Subject: [PATCH 04/17] moved lennard-jones files to src --- .../python/structurefinder/lj_potential}/LJ_MD_plot.py | 0 .../python/structurefinder/lj_potential}/LJ_potential.py | 0 .../lj_potential}/lennard_jones_potential_module.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {codes/modules/lennard_jones_potential_module => src/python/structurefinder/lj_potential}/LJ_MD_plot.py (100%) rename {codes/modules/lennard_jones_potential_module => src/python/structurefinder/lj_potential}/LJ_potential.py (100%) rename {codes/modules/lennard_jones_potential_module => src/python/structurefinder/lj_potential}/lennard_jones_potential_module.py (100%) diff --git a/codes/modules/lennard_jones_potential_module/LJ_MD_plot.py b/src/python/structurefinder/lj_potential/LJ_MD_plot.py similarity index 100% rename from codes/modules/lennard_jones_potential_module/LJ_MD_plot.py rename to src/python/structurefinder/lj_potential/LJ_MD_plot.py diff --git a/codes/modules/lennard_jones_potential_module/LJ_potential.py b/src/python/structurefinder/lj_potential/LJ_potential.py similarity index 100% rename from codes/modules/lennard_jones_potential_module/LJ_potential.py rename to src/python/structurefinder/lj_potential/LJ_potential.py diff --git a/codes/modules/lennard_jones_potential_module/lennard_jones_potential_module.py b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py similarity index 100% rename from codes/modules/lennard_jones_potential_module/lennard_jones_potential_module.py rename to src/python/structurefinder/lj_potential/lennard_jones_potential_module.py From 68bb191e770a968b85621b26b74e7a3071121946 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 27 Feb 2025 00:22:34 +0000 Subject: [PATCH 05/17] Committing clang-format changes --- .../lj_potential/LJ_MD_plot.py | 62 ++++++++++--------- .../lj_potential/LJ_potential.py | 48 ++++++++------ .../structurefinder/lj_potential/__init__.py | 13 ++++ .../lennard_jones_potential_module.py | 33 +++++++--- .../lj_potential/lj_potential.py | 20 +++--- 5 files changed, 112 insertions(+), 64 deletions(-) diff --git a/src/python/structurefinder/lj_potential/LJ_MD_plot.py b/src/python/structurefinder/lj_potential/LJ_MD_plot.py index 3971da4..1151fe5 100644 --- a/src/python/structurefinder/lj_potential/LJ_MD_plot.py +++ b/src/python/structurefinder/lj_potential/LJ_MD_plot.py @@ -1,5 +1,18 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# Copyright 2025 NWChemEx Community +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Created on Wed Aug 9 10:20:29 2023 @@ -10,46 +23,42 @@ import numpy as np import matplotlib as mpl from mpl_toolkits import mplot3d -import matplotlib.pyplot as plt +import matplotlib.pyplot as plt def LJ_MD_plot(points): - + # Activating latex rendering text plt.rcParams['text.usetex'] = True # Turn interactive plotting on #------------- - plt.ion() # <-- To be able to close graph and keep working + plt.ion() # <-- To be able to close graph and keep working #------------- on the console without the console get stuc # Definition of Figure and Axes #fig, axes = plt.subplots(1,1,figsize=(12,7),subplot_kw={'projection': '3d'}) - fig,axes=plt.subplots(1,1,figsize=(12,7)) - - + fig, axes = plt.subplots(1, 1, figsize=(12, 7)) def title_and_labels(ax): - ax.set_title('BE2 Optimization', fontsize = 25) + ax.set_title('BE2 Optimization', fontsize=25) ax.set_xlabel("$x$", fontsize=16) ax.set_ylabel("$y$", fontsize=16) #ax.set_zlabel("$f(x,y)$", fontsize=16) - - if len(points)<100: - x = np.linspace(0.92, 2, 500) - + + if len(points) < 100: + x = np.linspace(0.92, 2, 500) + else: x = np.linspace(0.92, 5, 500) - E = lambda x: 4*((1/x**12)-(1/x**6)) + E = lambda x: 4 * ((1 / x**12) - (1 / x**6)) - - - #-- Plot ---------------------------------------- + #-- Plot ---------------------------------------- #cp = axes.plot_surface(X, Y, Z, cmap=plt.cm.YlGnBu_r) - p = axes.plot(x,E(x), color ='k', alpha=0.5) + p = axes.plot(x, E(x), color='k', alpha=0.5) #axes.view_init(60, -63) #axes.view_init(45, -60) - #---- Axes configuration------------------------- + #---- Axes configuration------------------------- title_and_labels(axes) #----------------------------------------------- #--- Adding color bar to plot @@ -57,24 +66,19 @@ def title_and_labels(ax): #cb.set_label(r"$z$", fontsize=16) #------------- - - - -# x_coord = [] -# y_coord = [] + # x_coord = [] + # y_coord = [] for i in points: x = i[0] - - axes.scatter(x, E(x), c = "r", marker = '.') + + axes.scatter(x, E(x), c="r", marker='.') #axes.scatter(x,y, marker = ".", c = "r") <--- contour points in # in the same 3d graph projected to the xy-plnae - - if len(points)<100: + + if len(points) < 100: plt.xlim(0.7, 1.5) else: plt.xlim(0.7, 3.5) - - - + plt.savefig('NSTOVSUT_lennard-jones.png', bbox_inches='tight') plt.show() diff --git a/src/python/structurefinder/lj_potential/LJ_potential.py b/src/python/structurefinder/lj_potential/LJ_potential.py index 9f3b562..60d7941 100644 --- a/src/python/structurefinder/lj_potential/LJ_potential.py +++ b/src/python/structurefinder/lj_potential/LJ_potential.py @@ -1,5 +1,18 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +# Copyright 2025 NWChemEx Community +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ Created on Thu Aug 10 10:51:27 2023 @@ -8,6 +21,7 @@ import numpy as np + class Lennard_Jones_Potential(): """ This Class Evaluates the Spiral Potential Function, and calculates @@ -19,27 +33,25 @@ class Lennard_Jones_Potential(): Also as a way to check the analytical derivatives, numerical derivatives have been calculated. """ - - - def __init__(self,x_coordinate): - + + def __init__(self, x_coordinate): + x0 = x_coordinate - - + #-------------- LENNARD-JONES FUNCTION ---------------------------- - E = lambda x: 4*((1/x**12)-(1/x**6)) - + E = lambda x: 4 * ((1 / x**12) - (1 / x**6)) + #----------------------------------------------------------- - + #------------- ANALYTIC FORCE ------------------------------ - - DE_x = -24*((2/x0**13)-(1/x0**7)) + + DE_x = -24 * ((2 / x0**13) - (1 / x0**7)) FORCE_CARTESIAN = -DE_x - + #self.force_polar = FORCE_POLAR - self.force_cart = FORCE_CARTESIAN + self.force_cart = FORCE_CARTESIAN self.LJ_energy = E(x0) - + # 3. Numerical FORCE calculation ------------------------------ # Using Richardson Extrapolation to get O(h**4) by considering # The central formula approximation to the derivative @@ -47,7 +59,7 @@ def __init__(self,x_coordinate): # f'(x0) = (f(x0+h)-f(x0-h))/(2*h), O(h**2) # -------------------------------------------------------------- #Ec = lambda x, y: (a-x)**2 + b*(y-x**2)**2 - + #----------------------------------------------------------------- #N1x = lambda h: (Ec(x0+h,y0) - Ec(x0-h,y0))/(2*h) #Dx2 = (1/3)*(4*N1x(h/2)- N1x(h)) @@ -56,8 +68,6 @@ def __init__(self,x_coordinate): #Dy2 = (1/3)*(4*N1y(h/2)- N1y(h)) #---------------------------------------------------------------- #FORCE_NUMERICAL = -np.array([Dx2,Dy2]) - + #self.Ec = Ec(x0,y0) - #self.force_numerical = FORCE_NUMERICAL - - + #self.force_numerical = FORCE_NUMERICAL diff --git a/src/python/structurefinder/lj_potential/__init__.py b/src/python/structurefinder/lj_potential/__init__.py index e69de29..a8d4745 100644 --- a/src/python/structurefinder/lj_potential/__init__.py +++ b/src/python/structurefinder/lj_potential/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2025 NWChemEx Community +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py index 20770d7..0a619d3 100644 --- a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py +++ b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py @@ -1,3 +1,16 @@ +# Copyright 2025 NWChemEx Community +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ @author: Felix Rojas """ @@ -6,6 +19,7 @@ import plugandplay as pp from simde import TotalEnergy + class LJ_potential(pp.ModuleBase): # Module Construct -------------------------------------------------------- def __init__(self): @@ -15,8 +29,9 @@ def __init__(self): pp.ModuleBase.__init__(self) self.description("Lennard-Jones 1D potential function") self.satisfies_property_type(TotalEnergy()) + #-------------------------------------------------------------------------- - + # Module run_ member function --------------------------------------------- def run_(self, inputs): """ @@ -29,18 +44,20 @@ def run_(self, inputs): ------- E: Lennard-Jonnes 1D potential Energy, TYPE ---> Float - """ + """ pt = TotalEnergy() x0 = pt.unwrap_inputs(inputs) #-------------- LENNARD-JONES FUNCTION -------------------------------- - E = lambda x: 4*((1/x**12)-(1/x**6)) - #------------- ANALYTIC FORCE ----------------------------------------- - DE_x = -24*((2/x0**13)-(1/x0**7)) + E = lambda x: 4 * ((1 / x**12) - (1 / x**6)) + #------------- ANALYTIC FORCE ----------------------------------------- + DE_x = -24 * ((2 / x0**13) - (1 / x0**7)) FC = -DE_x #---------------------------------------------------------------------- - rv = self.results() + rv = self.results() return pt.wrap_results(rv, E(x0)) + #-------------------------------------------------------------------------- - + + def load_Lenard_Jones_potential(mm): - mm.add_module("Lenard-Jones", LJ_potential()) \ No newline at end of file + mm.add_module("Lenard-Jones", LJ_potential()) diff --git a/src/python/structurefinder/lj_potential/lj_potential.py b/src/python/structurefinder/lj_potential/lj_potential.py index ff116d4..cd7f9f2 100644 --- a/src/python/structurefinder/lj_potential/lj_potential.py +++ b/src/python/structurefinder/lj_potential/lj_potential.py @@ -15,6 +15,7 @@ import plugandplay as pp from simde import TotalEnergy + class LJ_potential(pp.ModuleBase): # Module Construct -------------------------------------------------------- def __init__(self): @@ -28,8 +29,9 @@ def __init__(self): pp.ModuleBase.__init__(self) self.description("Lennard-Jones 1D potential function") self.satisfies_property_type(TotalEnergy()) + #-------------------------------------------------------------------------- - + # Module run_ member function --------------------------------------------- def run_(self, inputs): """ @@ -48,18 +50,20 @@ def run_(self, inputs): FC = - dE/dx TYPE ---> Float - """ + """ pt = TotalEnergy() x0 = pt.unwrap_inputs(inputs) #-------------- LENNARD-JONES FUNCTION -------------------------------- - E = lambda x: 4*((1/x**12)-(1/x**6)) - #------------- ANALYTIC FORCE ----------------------------------------- - DE_x = -24*((2/x0**13)-(1/x0**7)) + E = lambda x: 4 * ((1 / x**12) - (1 / x**6)) + #------------- ANALYTIC FORCE ----------------------------------------- + DE_x = -24 * ((2 / x0**13) - (1 / x0**7)) FC = -DE_x #---------------------------------------------------------------------- - rv = self.results() - return pt.wrap_results(rv, E(x0),FC) + rv = self.results() + return pt.wrap_results(rv, E(x0), FC) + #-------------------------------------------------------------------------- - + + def load_Lenard_Jones_potential(mm): mm.add_module("Lenard-Jones", LJ_potential()) From eeb108f21fc414776d440fef5f10573b982c3e09 Mon Sep 17 00:00:00 2001 From: leothan Date: Wed, 5 Mar 2025 11:35:04 -0600 Subject: [PATCH 06/17] Lennard Jones Module with tests --- src/python/structurefinder/__init__.py | 3 +- .../lj_potential/LJ_MD_plot.py | 80 ------------------- .../lj_potential/LJ_potential.py | 63 --------------- .../lennard_jones_potential_module.py | 21 +++-- .../lj_potential/lj_potential.py | 65 --------------- .../test_lennard_jones_potential/__init__.py | 0 .../test_LJ_potential.py | 32 ++++++++ 7 files changed, 48 insertions(+), 216 deletions(-) delete mode 100644 src/python/structurefinder/lj_potential/LJ_MD_plot.py delete mode 100644 src/python/structurefinder/lj_potential/LJ_potential.py delete mode 100644 src/python/structurefinder/lj_potential/lj_potential.py create mode 100644 tests/python/unit_tests/test_lennard_jones_potential/__init__.py create mode 100644 tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py diff --git a/src/python/structurefinder/__init__.py b/src/python/structurefinder/__init__.py index b30b4bf..274cbeb 100644 --- a/src/python/structurefinder/__init__.py +++ b/src/python/structurefinder/__init__.py @@ -13,10 +13,11 @@ # limitations under the License. from .pyberny import load_pyberny_modules - +from .lj_potential.lennard_jones_potential_module import load_Lenard_Jones_potential def load_modules(mm): """ Loads the collection of all modules provided by StructureFinder. """ load_pyberny_modules(mm) + load_Lenard_Jones_potential(mm) diff --git a/src/python/structurefinder/lj_potential/LJ_MD_plot.py b/src/python/structurefinder/lj_potential/LJ_MD_plot.py deleted file mode 100644 index 3971da4..0000000 --- a/src/python/structurefinder/lj_potential/LJ_MD_plot.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -Created on Wed Aug 9 10:20:29 2023 - -@author: Felix Rojas -""" - -# Imported packages: -import numpy as np -import matplotlib as mpl -from mpl_toolkits import mplot3d -import matplotlib.pyplot as plt - - -def LJ_MD_plot(points): - - # Activating latex rendering text - plt.rcParams['text.usetex'] = True - # Turn interactive plotting on - #------------- - plt.ion() # <-- To be able to close graph and keep working - #------------- on the console without the console get stuc - - # Definition of Figure and Axes - #fig, axes = plt.subplots(1,1,figsize=(12,7),subplot_kw={'projection': '3d'}) - fig,axes=plt.subplots(1,1,figsize=(12,7)) - - - - def title_and_labels(ax): - ax.set_title('BE2 Optimization', fontsize = 25) - ax.set_xlabel("$x$", fontsize=16) - ax.set_ylabel("$y$", fontsize=16) - #ax.set_zlabel("$f(x,y)$", fontsize=16) - - if len(points)<100: - x = np.linspace(0.92, 2, 500) - - else: - x = np.linspace(0.92, 5, 500) - - E = lambda x: 4*((1/x**12)-(1/x**6)) - - - - #-- Plot ---------------------------------------- - #cp = axes.plot_surface(X, Y, Z, cmap=plt.cm.YlGnBu_r) - p = axes.plot(x,E(x), color ='k', alpha=0.5) - #axes.view_init(60, -63) - #axes.view_init(45, -60) - #---- Axes configuration------------------------- - title_and_labels(axes) - #----------------------------------------------- - #--- Adding color bar to plot - #cb = fig.colorbar(cp) # Add a colorbar to a plot - #cb.set_label(r"$z$", fontsize=16) - #------------- - - - - -# x_coord = [] -# y_coord = [] - for i in points: - x = i[0] - - axes.scatter(x, E(x), c = "r", marker = '.') - #axes.scatter(x,y, marker = ".", c = "r") <--- contour points in - # in the same 3d graph projected to the xy-plnae - - if len(points)<100: - plt.xlim(0.7, 1.5) - else: - plt.xlim(0.7, 3.5) - - - - plt.savefig('NSTOVSUT_lennard-jones.png', bbox_inches='tight') - plt.show() diff --git a/src/python/structurefinder/lj_potential/LJ_potential.py b/src/python/structurefinder/lj_potential/LJ_potential.py deleted file mode 100644 index 9f3b562..0000000 --- a/src/python/structurefinder/lj_potential/LJ_potential.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -Created on Thu Aug 10 10:51:27 2023 - -@author: Felix Rojas -""" - -import numpy as np - -class Lennard_Jones_Potential(): - """ - This Class Evaluates the Spiral Potential Function, and calculates - the Force in Polar and Cartesian coordinates. T - - The object of this class will have as atributes the force values in each - coordinate system and the spiral "energy" value. - - Also as a way to check the analytical derivatives, numerical derivatives - have been calculated. - """ - - - def __init__(self,x_coordinate): - - x0 = x_coordinate - - - #-------------- LENNARD-JONES FUNCTION ---------------------------- - E = lambda x: 4*((1/x**12)-(1/x**6)) - - #----------------------------------------------------------- - - #------------- ANALYTIC FORCE ------------------------------ - - DE_x = -24*((2/x0**13)-(1/x0**7)) - FORCE_CARTESIAN = -DE_x - - #self.force_polar = FORCE_POLAR - self.force_cart = FORCE_CARTESIAN - self.LJ_energy = E(x0) - - # 3. Numerical FORCE calculation ------------------------------ - # Using Richardson Extrapolation to get O(h**4) by considering - # The central formula approximation to the derivative - # - # f'(x0) = (f(x0+h)-f(x0-h))/(2*h), O(h**2) - # -------------------------------------------------------------- - #Ec = lambda x, y: (a-x)**2 + b*(y-x**2)**2 - - #----------------------------------------------------------------- - #N1x = lambda h: (Ec(x0+h,y0) - Ec(x0-h,y0))/(2*h) - #Dx2 = (1/3)*(4*N1x(h/2)- N1x(h)) - #----------------------------------------------------------------- - #N1y = lambda h: (Ec(x0,y0+h) - Ec(x0,y0-h))/(2*h) - #Dy2 = (1/3)*(4*N1y(h/2)- N1y(h)) - #---------------------------------------------------------------- - #FORCE_NUMERICAL = -np.array([Dx2,Dy2]) - - #self.Ec = Ec(x0,y0) - #self.force_numerical = FORCE_NUMERICAL - - diff --git a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py index 20770d7..09684d4 100644 --- a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py +++ b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py @@ -3,7 +3,7 @@ """ import numpy as np -import plugandplay as pp +import pluginplay as pp from simde import TotalEnergy class LJ_potential(pp.ModuleBase): @@ -18,7 +18,7 @@ def __init__(self): #-------------------------------------------------------------------------- # Module run_ member function --------------------------------------------- - def run_(self, inputs): + def run_(self, inputs, submods): """ Parameters ---------- @@ -31,15 +31,22 @@ def run_(self, inputs): TYPE ---> Float """ pt = TotalEnergy() - x0 = pt.unwrap_inputs(inputs) + chem_sys, = pt.unwrap_inputs(inputs) + mol = chem_sys.molecule + coor_0 = np.array([mol.at(0).x,mol.at(0).y,mol.at(0).z]) + coor_1 = np.array([mol.at(1).x,mol.at(1).y,mol.at(1).z]) + #---------------------------------------------------------------------- + assert(mol.size() == 2) #<--- To check molcule size contains 2-atoms + #---------------------------------------------------------------------- + r = np.linalg.norm(coor_0 - coor_1) #-------------- LENNARD-JONES FUNCTION -------------------------------- - E = lambda x: 4*((1/x**12)-(1/x**6)) + E = 4*((1/r**12)-(1/r**6)) #------------- ANALYTIC FORCE ----------------------------------------- - DE_x = -24*((2/x0**13)-(1/x0**7)) + DE_x = -24*((2/r**13)-(1/r**7)) FC = -DE_x #---------------------------------------------------------------------- - rv = self.results() - return pt.wrap_results(rv, E(x0)) + rv = self.results() + return pt.wrap_results(rv, E) #-------------------------------------------------------------------------- def load_Lenard_Jones_potential(mm): diff --git a/src/python/structurefinder/lj_potential/lj_potential.py b/src/python/structurefinder/lj_potential/lj_potential.py deleted file mode 100644 index ff116d4..0000000 --- a/src/python/structurefinder/lj_potential/lj_potential.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2025 NWChemEx Community -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import numpy as np -import plugandplay as pp -from simde import TotalEnergy - -class LJ_potential(pp.ModuleBase): - # Module Construct -------------------------------------------------------- - def __init__(self): - """ - This module Evaluates the Lennard-Jones 1D potential function (E), and - calculates minus the gradient (Force) in Cartesian coordinates, - according to the relation - - FC = - dE/dx - """ - pp.ModuleBase.__init__(self) - self.description("Lennard-Jones 1D potential function") - self.satisfies_property_type(TotalEnergy()) - #-------------------------------------------------------------------------- - - # Module run_ member function --------------------------------------------- - def run_(self, inputs): - """ - Parameters - ---------- - inputs : x-coordinate, - TYPE ---> Float - - Returns - ------- - E: Lennard-Jonnes 1D potential Energy, - TYPE ---> Float - - FC: Force in cartesian coordinates evaluated at the given input, - acording to the relation - FC = - dE/dx - - TYPE ---> Float - """ - pt = TotalEnergy() - x0 = pt.unwrap_inputs(inputs) - #-------------- LENNARD-JONES FUNCTION -------------------------------- - E = lambda x: 4*((1/x**12)-(1/x**6)) - #------------- ANALYTIC FORCE ----------------------------------------- - DE_x = -24*((2/x0**13)-(1/x0**7)) - FC = -DE_x - #---------------------------------------------------------------------- - rv = self.results() - return pt.wrap_results(rv, E(x0),FC) - #-------------------------------------------------------------------------- - -def load_Lenard_Jones_potential(mm): - mm.add_module("Lenard-Jones", LJ_potential()) diff --git a/tests/python/unit_tests/test_lennard_jones_potential/__init__.py b/tests/python/unit_tests/test_lennard_jones_potential/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py b/tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py new file mode 100644 index 0000000..1b8bb72 --- /dev/null +++ b/tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py @@ -0,0 +1,32 @@ +# Copyright 2024 NWChemEx Community +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import structurefinder +import nwchemex +import pluginplay as pp +import chemist +import unittest +from simde import TotalEnergy + +class Test_Lennard_jones_potential(unittest.TestCase): + + def test_lennard_jones_potential(self): + result = self.mm.run_as(TotalEnergy(),"Lenard-Jones", chemist.ChemicalSystem(self.mol)) + self.assertEqual(result,-1.0) + + def setUp(self): + self.mm = pp.ModuleManager() + structurefinder.load_modules(self.mm) + self.mol = chemist.Molecule() + self.mol.push_back(chemist.Atom("H", 1, 1.0079, 0.0, 0.0, 0.0)) + self.mol.push_back(chemist.Atom("H", 1, 1.0079, 0.0, 0.0, 2**(1/6))) \ No newline at end of file From b64903bcb3fed312f33332a21babd3551b1cec27 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 5 Mar 2025 17:46:57 +0000 Subject: [PATCH 07/17] Committing clang-format changes --- src/python/structurefinder/__init__.py | 1 + .../lennard_jones_potential_module.py | 15 ++++++++------- .../test_lennard_jones_potential/__init__.py | 13 +++++++++++++ .../test_LJ_potential.py | 8 +++++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/python/structurefinder/__init__.py b/src/python/structurefinder/__init__.py index 274cbeb..ac881bc 100644 --- a/src/python/structurefinder/__init__.py +++ b/src/python/structurefinder/__init__.py @@ -15,6 +15,7 @@ from .pyberny import load_pyberny_modules from .lj_potential.lennard_jones_potential_module import load_Lenard_Jones_potential + def load_modules(mm): """ Loads the collection of all modules provided by StructureFinder. diff --git a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py index 34e222e..5ddb36a 100644 --- a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py +++ b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py @@ -48,20 +48,21 @@ def run_(self, inputs, submods): pt = TotalEnergy() chem_sys, = pt.unwrap_inputs(inputs) mol = chem_sys.molecule - coor_0 = np.array([mol.at(0).x,mol.at(0).y,mol.at(0).z]) - coor_1 = np.array([mol.at(1).x,mol.at(1).y,mol.at(1).z]) + coor_0 = np.array([mol.at(0).x, mol.at(0).y, mol.at(0).z]) + coor_1 = np.array([mol.at(1).x, mol.at(1).y, mol.at(1).z]) #---------------------------------------------------------------------- - assert(mol.size() == 2) #<--- To check molcule size contains 2-atoms + assert (mol.size() == 2) #<--- To check molcule size contains 2-atoms #---------------------------------------------------------------------- r = np.linalg.norm(coor_0 - coor_1) #-------------- LENNARD-JONES FUNCTION -------------------------------- - E = 4*((1/r**12)-(1/r**6)) - #------------- ANALYTIC FORCE ----------------------------------------- - DE_x = -24*((2/r**13)-(1/r**7)) + E = 4 * ((1 / r**12) - (1 / r**6)) + #------------- ANALYTIC FORCE ----------------------------------------- + DE_x = -24 * ((2 / r**13) - (1 / r**7)) FC = -DE_x #---------------------------------------------------------------------- - rv = self.results() + rv = self.results() return pt.wrap_results(rv, E) + #-------------------------------------------------------------------------- diff --git a/tests/python/unit_tests/test_lennard_jones_potential/__init__.py b/tests/python/unit_tests/test_lennard_jones_potential/__init__.py index e69de29..a8d4745 100644 --- a/tests/python/unit_tests/test_lennard_jones_potential/__init__.py +++ b/tests/python/unit_tests/test_lennard_jones_potential/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2025 NWChemEx Community +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py b/tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py index 1b8bb72..7536cf3 100644 --- a/tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py +++ b/tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py @@ -18,15 +18,17 @@ import unittest from simde import TotalEnergy + class Test_Lennard_jones_potential(unittest.TestCase): def test_lennard_jones_potential(self): - result = self.mm.run_as(TotalEnergy(),"Lenard-Jones", chemist.ChemicalSystem(self.mol)) - self.assertEqual(result,-1.0) + result = self.mm.run_as(TotalEnergy(), "Lenard-Jones", + chemist.ChemicalSystem(self.mol)) + self.assertEqual(result, -1.0) def setUp(self): self.mm = pp.ModuleManager() structurefinder.load_modules(self.mm) self.mol = chemist.Molecule() self.mol.push_back(chemist.Atom("H", 1, 1.0079, 0.0, 0.0, 0.0)) - self.mol.push_back(chemist.Atom("H", 1, 1.0079, 0.0, 0.0, 2**(1/6))) \ No newline at end of file + self.mol.push_back(chemist.Atom("H", 1, 1.0079, 0.0, 0.0, 2**(1 / 6))) From 426ca98fdcc97b391dbb0a77ed9ad3187323d8ba Mon Sep 17 00:00:00 2001 From: leothan Date: Wed, 12 Mar 2025 17:26:48 -0500 Subject: [PATCH 08/17] lenard jones module PEP8 changes --- .../lj_potential/lennard_jones_potential_module.py | 6 +++--- ...test_LJ_potential.py => test_lennard_jones_potential.py} | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename tests/python/unit_tests/test_lennard_jones_potential/{test_LJ_potential.py => test_lennard_jones_potential.py} (95%) diff --git a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py index 5ddb36a..08a2dd6 100644 --- a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py +++ b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py @@ -20,7 +20,7 @@ from simde import TotalEnergy -class LJ_potential(pp.ModuleBase): +class LennardJonesPotential(pp.ModuleBase): # Module Construct -------------------------------------------------------- def __init__(self): """ @@ -66,5 +66,5 @@ def run_(self, inputs, submods): #-------------------------------------------------------------------------- -def load_Lenard_Jones_potential(mm): - mm.add_module("Lenard-Jones", LJ_potential()) +def load_lenard_jones_potential(mm): + mm.add_module("Lenard-Jones", LennardJonesPotential()) diff --git a/tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py b/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py similarity index 95% rename from tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py rename to tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py index 7536cf3..691d12b 100644 --- a/tests/python/unit_tests/test_lennard_jones_potential/test_LJ_potential.py +++ b/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py @@ -19,7 +19,7 @@ from simde import TotalEnergy -class Test_Lennard_jones_potential(unittest.TestCase): +class TestLennardJonesPotential(unittest.TestCase): def test_lennard_jones_potential(self): result = self.mm.run_as(TotalEnergy(), "Lenard-Jones", From 67aba50820273a79f7fa2200b60817d7ad97a9ba Mon Sep 17 00:00:00 2001 From: leothan Date: Thu, 13 Mar 2025 15:50:12 -0500 Subject: [PATCH 09/17] changes to __init__ and removal of lj_potential.py --- src/python/structurefinder/__init__.py | 2 +- .../lj_potential/lj_potential.py | 69 ------------------- 2 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 src/python/structurefinder/lj_potential/lj_potential.py diff --git a/src/python/structurefinder/__init__.py b/src/python/structurefinder/__init__.py index ac881bc..80d7d8c 100644 --- a/src/python/structurefinder/__init__.py +++ b/src/python/structurefinder/__init__.py @@ -13,7 +13,7 @@ # limitations under the License. from .pyberny import load_pyberny_modules -from .lj_potential.lennard_jones_potential_module import load_Lenard_Jones_potential +from .lj_potential.lennard_jones_potential_module import load_lenard_jones_potential def load_modules(mm): diff --git a/src/python/structurefinder/lj_potential/lj_potential.py b/src/python/structurefinder/lj_potential/lj_potential.py deleted file mode 100644 index cd7f9f2..0000000 --- a/src/python/structurefinder/lj_potential/lj_potential.py +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright 2025 NWChemEx Community -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import numpy as np -import plugandplay as pp -from simde import TotalEnergy - - -class LJ_potential(pp.ModuleBase): - # Module Construct -------------------------------------------------------- - def __init__(self): - """ - This module Evaluates the Lennard-Jones 1D potential function (E), and - calculates minus the gradient (Force) in Cartesian coordinates, - according to the relation - - FC = - dE/dx - """ - pp.ModuleBase.__init__(self) - self.description("Lennard-Jones 1D potential function") - self.satisfies_property_type(TotalEnergy()) - - #-------------------------------------------------------------------------- - - # Module run_ member function --------------------------------------------- - def run_(self, inputs): - """ - Parameters - ---------- - inputs : x-coordinate, - TYPE ---> Float - - Returns - ------- - E: Lennard-Jonnes 1D potential Energy, - TYPE ---> Float - - FC: Force in cartesian coordinates evaluated at the given input, - acording to the relation - FC = - dE/dx - - TYPE ---> Float - """ - pt = TotalEnergy() - x0 = pt.unwrap_inputs(inputs) - #-------------- LENNARD-JONES FUNCTION -------------------------------- - E = lambda x: 4 * ((1 / x**12) - (1 / x**6)) - #------------- ANALYTIC FORCE ----------------------------------------- - DE_x = -24 * ((2 / x0**13) - (1 / x0**7)) - FC = -DE_x - #---------------------------------------------------------------------- - rv = self.results() - return pt.wrap_results(rv, E(x0), FC) - - #-------------------------------------------------------------------------- - - -def load_Lenard_Jones_potential(mm): - mm.add_module("Lenard-Jones", LJ_potential()) From 36935972a893da70924f59f042d6cafd924508ee Mon Sep 17 00:00:00 2001 From: leothan Date: Fri, 14 Mar 2025 11:25:10 -0500 Subject: [PATCH 10/17] __init__.py change from Ryan's coment --- CMakeLists.txt | 2 +- .../structurefinder/.spyproject/config/codestyle.ini | 8 ++++++++ .../config/defaults/defaults-codestyle-0.2.0.ini | 5 +++++ .../config/defaults/defaults-encoding-0.2.0.ini | 3 +++ .../config/defaults/defaults-vcs-0.2.0.ini | 4 ++++ .../config/defaults/defaults-workspace-0.2.0.ini | 6 ++++++ .../structurefinder/.spyproject/config/encoding.ini | 6 ++++++ .../structurefinder/.spyproject/config/vcs.ini | 7 +++++++ .../structurefinder/.spyproject/config/workspace.ini | 12 ++++++++++++ src/python/structurefinder/__init__.py | 2 +- 10 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/python/structurefinder/.spyproject/config/codestyle.ini create mode 100644 src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini create mode 100644 src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini create mode 100644 src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini create mode 100644 src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini create mode 100644 src/python/structurefinder/.spyproject/config/encoding.ini create mode 100644 src/python/structurefinder/.spyproject/config/vcs.ini create mode 100644 src/python/structurefinder/.spyproject/config/workspace.ini diff --git a/CMakeLists.txt b/CMakeLists.txt index 056a394..b75fc90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ if("${BUILD_TESTING}") py_${PROJECT_NAME} "${${PROJECT_NAME}_PYTHON_TEST_DIR}/unit_tests/test_${PROJECT_NAME}.py" DEPENDS nwchemex - SUBMODULES simde chemist pluginplay parallelzone friendzone chemcache nwchemex + SUBMODULES simde chemist pluginplay parallelzone friendzone chemcache nwchemex tensorwrapper integrals ) endif() diff --git a/src/python/structurefinder/.spyproject/config/codestyle.ini b/src/python/structurefinder/.spyproject/config/codestyle.ini new file mode 100644 index 0000000..0f54b4c --- /dev/null +++ b/src/python/structurefinder/.spyproject/config/codestyle.ini @@ -0,0 +1,8 @@ +[codestyle] +indentation = True +edge_line = True +edge_line_columns = 79 + +[main] +version = 0.2.0 + diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini new file mode 100644 index 0000000..0b95e5c --- /dev/null +++ b/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini @@ -0,0 +1,5 @@ +[codestyle] +indentation = True +edge_line = True +edge_line_columns = 79 + diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini new file mode 100644 index 0000000..0ce193c --- /dev/null +++ b/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini @@ -0,0 +1,3 @@ +[encoding] +text_encoding = utf-8 + diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini new file mode 100644 index 0000000..ee25483 --- /dev/null +++ b/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini @@ -0,0 +1,4 @@ +[vcs] +use_version_control = False +version_control_system = + diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini new file mode 100644 index 0000000..2a73ab7 --- /dev/null +++ b/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini @@ -0,0 +1,6 @@ +[workspace] +restore_data_on_startup = True +save_data_on_exit = True +save_history = True +save_non_project_files = False + diff --git a/src/python/structurefinder/.spyproject/config/encoding.ini b/src/python/structurefinder/.spyproject/config/encoding.ini new file mode 100644 index 0000000..a17aced --- /dev/null +++ b/src/python/structurefinder/.spyproject/config/encoding.ini @@ -0,0 +1,6 @@ +[encoding] +text_encoding = utf-8 + +[main] +version = 0.2.0 + diff --git a/src/python/structurefinder/.spyproject/config/vcs.ini b/src/python/structurefinder/.spyproject/config/vcs.ini new file mode 100644 index 0000000..fd66eae --- /dev/null +++ b/src/python/structurefinder/.spyproject/config/vcs.ini @@ -0,0 +1,7 @@ +[vcs] +use_version_control = False +version_control_system = + +[main] +version = 0.2.0 + diff --git a/src/python/structurefinder/.spyproject/config/workspace.ini b/src/python/structurefinder/.spyproject/config/workspace.ini new file mode 100644 index 0000000..a596309 --- /dev/null +++ b/src/python/structurefinder/.spyproject/config/workspace.ini @@ -0,0 +1,12 @@ +[workspace] +restore_data_on_startup = True +save_data_on_exit = True +save_history = True +save_non_project_files = False +project_type = 'empty-project-type' +recent_files = ['../../../../../../../../../../.config/spyder-py3/temp.py', '__init__.py'] + +[main] +version = 0.2.0 +recent_files = [] + diff --git a/src/python/structurefinder/__init__.py b/src/python/structurefinder/__init__.py index 80d7d8c..642b4c3 100644 --- a/src/python/structurefinder/__init__.py +++ b/src/python/structurefinder/__init__.py @@ -21,4 +21,4 @@ def load_modules(mm): Loads the collection of all modules provided by StructureFinder. """ load_pyberny_modules(mm) - load_Lenard_Jones_potential(mm) + load_lenard_jones_potential(mm) From 412bd2cf401418590ede9ba55bab15bc2ead8b42 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 14 Mar 2025 16:25:51 +0000 Subject: [PATCH 11/17] Committing clang-format changes --- .../.spyproject/config/codestyle.ini | 14 ++++++++++++++ .../config/defaults/defaults-codestyle-0.2.0.ini | 14 ++++++++++++++ .../config/defaults/defaults-encoding-0.2.0.ini | 14 ++++++++++++++ .../config/defaults/defaults-vcs-0.2.0.ini | 14 ++++++++++++++ .../config/defaults/defaults-workspace-0.2.0.ini | 14 ++++++++++++++ .../.spyproject/config/encoding.ini | 14 ++++++++++++++ .../structurefinder/.spyproject/config/vcs.ini | 14 ++++++++++++++ .../.spyproject/config/workspace.ini | 14 ++++++++++++++ 8 files changed, 112 insertions(+) diff --git a/src/python/structurefinder/.spyproject/config/codestyle.ini b/src/python/structurefinder/.spyproject/config/codestyle.ini index 0f54b4c..21eca9c 100644 --- a/src/python/structurefinder/.spyproject/config/codestyle.ini +++ b/src/python/structurefinder/.spyproject/config/codestyle.ini @@ -1,3 +1,17 @@ +; Copyright 2025 NWChemEx Community +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. + [codestyle] indentation = True edge_line = True diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini index 0b95e5c..48d1f63 100644 --- a/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini +++ b/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini @@ -1,3 +1,17 @@ +; Copyright 2025 NWChemEx Community +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. + [codestyle] indentation = True edge_line = True diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini index 0ce193c..459c836 100644 --- a/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini +++ b/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini @@ -1,3 +1,17 @@ +; Copyright 2025 NWChemEx Community +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. + [encoding] text_encoding = utf-8 diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini index ee25483..022e2bc 100644 --- a/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini +++ b/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini @@ -1,3 +1,17 @@ +; Copyright 2025 NWChemEx Community +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. + [vcs] use_version_control = False version_control_system = diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini index 2a73ab7..d2f0b33 100644 --- a/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini +++ b/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini @@ -1,3 +1,17 @@ +; Copyright 2025 NWChemEx Community +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. + [workspace] restore_data_on_startup = True save_data_on_exit = True diff --git a/src/python/structurefinder/.spyproject/config/encoding.ini b/src/python/structurefinder/.spyproject/config/encoding.ini index a17aced..65941fe 100644 --- a/src/python/structurefinder/.spyproject/config/encoding.ini +++ b/src/python/structurefinder/.spyproject/config/encoding.ini @@ -1,3 +1,17 @@ +; Copyright 2025 NWChemEx Community +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. + [encoding] text_encoding = utf-8 diff --git a/src/python/structurefinder/.spyproject/config/vcs.ini b/src/python/structurefinder/.spyproject/config/vcs.ini index fd66eae..5002d6e 100644 --- a/src/python/structurefinder/.spyproject/config/vcs.ini +++ b/src/python/structurefinder/.spyproject/config/vcs.ini @@ -1,3 +1,17 @@ +; Copyright 2025 NWChemEx Community +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. + [vcs] use_version_control = False version_control_system = diff --git a/src/python/structurefinder/.spyproject/config/workspace.ini b/src/python/structurefinder/.spyproject/config/workspace.ini index a596309..9532d86 100644 --- a/src/python/structurefinder/.spyproject/config/workspace.ini +++ b/src/python/structurefinder/.spyproject/config/workspace.ini @@ -1,3 +1,17 @@ +; Copyright 2025 NWChemEx Community +; +; Licensed under the Apache License, Version 2.0 (the "License"); +; you may not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an "AS IS" BASIS, +; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. + [workspace] restore_data_on_startup = True save_data_on_exit = True From eb22c14ba5d2d2823f06da51bd7a27fa5c5b1047 Mon Sep 17 00:00:00 2001 From: leothan Date: Fri, 14 Mar 2025 15:13:52 -0500 Subject: [PATCH 12/17] clean up --- CMakeLists.txt | 2 +- src/python/structurefinder/__init__.py | 4 ++-- .../lj_potential/lennard_jones_potential_module.py | 4 ++-- .../test_lennard_jones_potential.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b75fc90..5858706 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ if("${BUILD_TESTING}") py_${PROJECT_NAME} "${${PROJECT_NAME}_PYTHON_TEST_DIR}/unit_tests/test_${PROJECT_NAME}.py" DEPENDS nwchemex - SUBMODULES simde chemist pluginplay parallelzone friendzone chemcache nwchemex tensorwrapper integrals + SUBMODULES simde chemist pluginplay parallelzone friendzone chemcache nwchemex tensorwrapper integrals scf nux ) endif() diff --git a/src/python/structurefinder/__init__.py b/src/python/structurefinder/__init__.py index 642b4c3..4de7eee 100644 --- a/src/python/structurefinder/__init__.py +++ b/src/python/structurefinder/__init__.py @@ -13,7 +13,7 @@ # limitations under the License. from .pyberny import load_pyberny_modules -from .lj_potential.lennard_jones_potential_module import load_lenard_jones_potential +from .lj_potential.lennard_jones_potential_module import load_lennard_jones_potential def load_modules(mm): @@ -21,4 +21,4 @@ def load_modules(mm): Loads the collection of all modules provided by StructureFinder. """ load_pyberny_modules(mm) - load_lenard_jones_potential(mm) + load_lennard_jones_potential(mm) diff --git a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py index 08a2dd6..d555d87 100644 --- a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py +++ b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py @@ -66,5 +66,5 @@ def run_(self, inputs, submods): #-------------------------------------------------------------------------- -def load_lenard_jones_potential(mm): - mm.add_module("Lenard-Jones", LennardJonesPotential()) +def load_lennard_jones_potential(mm): + mm.add_module("Lennard-Jones", LennardJonesPotential()) diff --git a/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py b/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py index 691d12b..03c92ec 100644 --- a/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py +++ b/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py @@ -22,7 +22,7 @@ class TestLennardJonesPotential(unittest.TestCase): def test_lennard_jones_potential(self): - result = self.mm.run_as(TotalEnergy(), "Lenard-Jones", + result = self.mm.run_as(TotalEnergy(), "Lennard-Jones", chemist.ChemicalSystem(self.mol)) self.assertEqual(result, -1.0) From 1dfcf78b4a9413330b9e36f36aef85cd2acc5afb Mon Sep 17 00:00:00 2001 From: leothan Date: Fri, 14 Mar 2025 15:15:53 -0500 Subject: [PATCH 13/17] spyproject folder deleted --- .../.spyproject/config/codestyle.ini | 22 ---------------- .../defaults/defaults-codestyle-0.2.0.ini | 19 -------------- .../defaults/defaults-encoding-0.2.0.ini | 17 ------------ .../config/defaults/defaults-vcs-0.2.0.ini | 18 ------------- .../defaults/defaults-workspace-0.2.0.ini | 20 -------------- .../.spyproject/config/encoding.ini | 20 -------------- .../.spyproject/config/vcs.ini | 21 --------------- .../.spyproject/config/workspace.ini | 26 ------------------- 8 files changed, 163 deletions(-) delete mode 100644 src/python/structurefinder/.spyproject/config/codestyle.ini delete mode 100644 src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini delete mode 100644 src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini delete mode 100644 src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini delete mode 100644 src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini delete mode 100644 src/python/structurefinder/.spyproject/config/encoding.ini delete mode 100644 src/python/structurefinder/.spyproject/config/vcs.ini delete mode 100644 src/python/structurefinder/.spyproject/config/workspace.ini diff --git a/src/python/structurefinder/.spyproject/config/codestyle.ini b/src/python/structurefinder/.spyproject/config/codestyle.ini deleted file mode 100644 index 21eca9c..0000000 --- a/src/python/structurefinder/.spyproject/config/codestyle.ini +++ /dev/null @@ -1,22 +0,0 @@ -; Copyright 2025 NWChemEx Community -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. - -[codestyle] -indentation = True -edge_line = True -edge_line_columns = 79 - -[main] -version = 0.2.0 - diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini deleted file mode 100644 index 48d1f63..0000000 --- a/src/python/structurefinder/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini +++ /dev/null @@ -1,19 +0,0 @@ -; Copyright 2025 NWChemEx Community -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. - -[codestyle] -indentation = True -edge_line = True -edge_line_columns = 79 - diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini deleted file mode 100644 index 459c836..0000000 --- a/src/python/structurefinder/.spyproject/config/defaults/defaults-encoding-0.2.0.ini +++ /dev/null @@ -1,17 +0,0 @@ -; Copyright 2025 NWChemEx Community -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. - -[encoding] -text_encoding = utf-8 - diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini deleted file mode 100644 index 022e2bc..0000000 --- a/src/python/structurefinder/.spyproject/config/defaults/defaults-vcs-0.2.0.ini +++ /dev/null @@ -1,18 +0,0 @@ -; Copyright 2025 NWChemEx Community -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. - -[vcs] -use_version_control = False -version_control_system = - diff --git a/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini b/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini deleted file mode 100644 index d2f0b33..0000000 --- a/src/python/structurefinder/.spyproject/config/defaults/defaults-workspace-0.2.0.ini +++ /dev/null @@ -1,20 +0,0 @@ -; Copyright 2025 NWChemEx Community -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. - -[workspace] -restore_data_on_startup = True -save_data_on_exit = True -save_history = True -save_non_project_files = False - diff --git a/src/python/structurefinder/.spyproject/config/encoding.ini b/src/python/structurefinder/.spyproject/config/encoding.ini deleted file mode 100644 index 65941fe..0000000 --- a/src/python/structurefinder/.spyproject/config/encoding.ini +++ /dev/null @@ -1,20 +0,0 @@ -; Copyright 2025 NWChemEx Community -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. - -[encoding] -text_encoding = utf-8 - -[main] -version = 0.2.0 - diff --git a/src/python/structurefinder/.spyproject/config/vcs.ini b/src/python/structurefinder/.spyproject/config/vcs.ini deleted file mode 100644 index 5002d6e..0000000 --- a/src/python/structurefinder/.spyproject/config/vcs.ini +++ /dev/null @@ -1,21 +0,0 @@ -; Copyright 2025 NWChemEx Community -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. - -[vcs] -use_version_control = False -version_control_system = - -[main] -version = 0.2.0 - diff --git a/src/python/structurefinder/.spyproject/config/workspace.ini b/src/python/structurefinder/.spyproject/config/workspace.ini deleted file mode 100644 index 9532d86..0000000 --- a/src/python/structurefinder/.spyproject/config/workspace.ini +++ /dev/null @@ -1,26 +0,0 @@ -; Copyright 2025 NWChemEx Community -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. - -[workspace] -restore_data_on_startup = True -save_data_on_exit = True -save_history = True -save_non_project_files = False -project_type = 'empty-project-type' -recent_files = ['../../../../../../../../../../.config/spyder-py3/temp.py', '__init__.py'] - -[main] -version = 0.2.0 -recent_files = [] - From 9e906e3b2f0a12b8fc323dbb2498408d5172b835 Mon Sep 17 00:00:00 2001 From: leothan Date: Fri, 14 Mar 2025 16:24:30 -0500 Subject: [PATCH 14/17] fix return type --- .../lj_potential/lennard_jones_potential_module.py | 3 ++- .../test_lennard_jones_potential.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py index d555d87..5f5be41 100644 --- a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py +++ b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py @@ -18,7 +18,7 @@ import numpy as np import pluginplay as pp from simde import TotalEnergy - +import tensorwrapper as tw class LennardJonesPotential(pp.ModuleBase): # Module Construct -------------------------------------------------------- @@ -60,6 +60,7 @@ def run_(self, inputs, submods): DE_x = -24 * ((2 / r**13) - (1 / r**7)) FC = -DE_x #---------------------------------------------------------------------- + E = tw.Tensor(np.array(E)) rv = self.results() return pt.wrap_results(rv, E) diff --git a/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py b/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py index 03c92ec..745b2e2 100644 --- a/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py +++ b/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import structurefinder import nwchemex import pluginplay as pp @@ -24,7 +25,7 @@ class TestLennardJonesPotential(unittest.TestCase): def test_lennard_jones_potential(self): result = self.mm.run_as(TotalEnergy(), "Lennard-Jones", chemist.ChemicalSystem(self.mol)) - self.assertEqual(result, -1.0) + self.assertEqual(np.array(result), -1.0) def setUp(self): self.mm = pp.ModuleManager() From 312cdcd90bc7de40e97a0189a3348a03c121f24e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 14 Mar 2025 21:25:13 +0000 Subject: [PATCH 15/17] Committing clang-format changes --- .../lj_potential/lennard_jones_potential_module.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py index 5f5be41..6d67d1b 100644 --- a/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py +++ b/src/python/structurefinder/lj_potential/lennard_jones_potential_module.py @@ -20,6 +20,7 @@ from simde import TotalEnergy import tensorwrapper as tw + class LennardJonesPotential(pp.ModuleBase): # Module Construct -------------------------------------------------------- def __init__(self): From 41d271a9acc62c7109206139e7534e897dbef8c6 Mon Sep 17 00:00:00 2001 From: Jacob Heflin Date: Sat, 15 Mar 2025 17:27:31 -0500 Subject: [PATCH 16/17] put band-aid on PyBerny --- src/python/structurefinder/pyberny/__init__.py | 3 ++- tests/python/unit_tests/test_optimizers/test_pybernyop.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/python/structurefinder/pyberny/__init__.py b/src/python/structurefinder/pyberny/__init__.py index 886f192..f3c005c 100644 --- a/src/python/structurefinder/pyberny/__init__.py +++ b/src/python/structurefinder/pyberny/__init__.py @@ -16,6 +16,7 @@ from simde import EnergyNuclearGradientStdVectorD, TotalEnergy, MoleculeFromString from berny import Berny, geomlib import chemist +import numpy as np class GeomoptViaPyberny(pp.ModuleBase): @@ -70,7 +71,7 @@ def run_(self, inputs, submods): EnergyNuclearGradientStdVectorD(), geom, geom_points.as_point_set()) print('Interim gradient: \n' + str(gradients) + '\n') - optimizer.send((energy, gradients)) + optimizer.send((np.array(energy).item(), gradients)) opt_geom = geom.molecule.nuclei print( diff --git a/tests/python/unit_tests/test_optimizers/test_pybernyop.py b/tests/python/unit_tests/test_optimizers/test_pybernyop.py index 26611e6..f7a948b 100644 --- a/tests/python/unit_tests/test_optimizers/test_pybernyop.py +++ b/tests/python/unit_tests/test_optimizers/test_pybernyop.py @@ -14,6 +14,7 @@ import structurefinder import nwchemex +import numpy as np import pluginplay as pp import chemist import unittest @@ -35,7 +36,8 @@ def test_optimize_pyberny(self): egy = mm.run_as(TotalEnergy(), "PyBerny", chemist.ChemicalSystem(self.mol)) print("Energy = " + str(egy)) - self.assertAlmostEqual(egy, -1.117505879316, 10) + print(np.array(egy).item()) + self.assertAlmostEqual(np.array(egy).item(), -1.117505879316, 10) def setUp(self): self.mol = chemist.Molecule() From 27a3497f7b8740c2345def8045ca04bb3ecb6d3c Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Mon, 17 Mar 2025 14:53:35 -0500 Subject: [PATCH 17/17] Update tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py --- .../test_lennard_jones_potential.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py b/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py index 745b2e2..0dc59c1 100644 --- a/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py +++ b/tests/python/unit_tests/test_lennard_jones_potential/test_lennard_jones_potential.py @@ -25,7 +25,7 @@ class TestLennardJonesPotential(unittest.TestCase): def test_lennard_jones_potential(self): result = self.mm.run_as(TotalEnergy(), "Lennard-Jones", chemist.ChemicalSystem(self.mol)) - self.assertEqual(np.array(result), -1.0) + self.assertEqual(np.array(result).item(), -1.0) def setUp(self): self.mm = pp.ModuleManager()