From 9168c8a0283be5ce08ab615e3ba9fef8e4c49ad5 Mon Sep 17 00:00:00 2001 From: Fel1-x <150053138+Fel1-x@users.noreply.github.com> Date: Fri, 7 Mar 2025 11:23:39 +0000 Subject: [PATCH 1/3] addded a new method to represample where oscillator strengths can be used directly --- repsample_acetylcall.py | 12 ++---------- src/pyneapples/rep_sampler_2d.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/repsample_acetylcall.py b/repsample_acetylcall.py index 06fcc2d..e608f6d 100644 --- a/repsample_acetylcall.py +++ b/repsample_acetylcall.py @@ -30,18 +30,10 @@ oscillator_strengths_array = np.array(oscillator_strengths) excitation_energies_cm_array = np.array(excitation_energies_cm) -excitation_energies_ev_array = excitation_energies_cm_array*(0.0001239841984) -excitation_energies_help_array = excitation_energies_ev_array/27.211396 -tdpx = np.sqrt((3*oscillator_strengths_array)/(2*excitation_energies_help_array)) - -trans_dip_mom_y = np.zeros((2000,3)) -trans_dip_mom_z = np.zeros((2000,3)) - -MYGEOM = rstd.GeomReduction(2000, 3, 20, 1000, 8, 16, weighted=True, pdfcomp = "KLdiv", intweights=False, verbose=False, dim1=False) #create an instance of GeomReduction with specified parameters: 500 samples, 3 states, 20 representative molecules, 100 cycles, 1 core, 1 job, without weighting, using KL divergence for PDF comparison, no integer weights, and verbose off +MYGEOM = rstd.GeomReduction(2000, 3, 5, 1000, 8, 16, weighted=True, pdfcomp = "KLdiv", intweights=False, verbose=False, dim1=False) #create an instance of GeomReduction with specified parameters: 500 samples, 3 states, 20 representative molecules, 100 cycles, 1 core, 1 job, without weighting, using KL divergence for PDF comparison, no integer weights, and verbose off np.random.seed(42) #set the seed for reproducibility - -MYGEOM.read_data_direct(excitation_energies_ev_array, tdpx, trans_dip_mom_y, trans_dip_mom_z) #directly feed the generated data into the GeomReduction instance +MYGEOM.read_data_direct_osc(excitation_energies_cm_array, oscillator_strengths_array) #directly feed the generated data into the GeomReduction instance MYGEOM.reduce_geoms() #start the geometry reduction process to select representative geometries diff --git a/src/pyneapples/rep_sampler_2d.py b/src/pyneapples/rep_sampler_2d.py index 1a2887c..f3402c8 100644 --- a/src/pyneapples/rep_sampler_2d.py +++ b/src/pyneapples/rep_sampler_2d.py @@ -212,6 +212,18 @@ def read_data_direct(self, excitation_energies, transition_dipole_moments_x, tra self.weights = self.exc*self.trans #calculate the weight for each transition as the product of excitation energy and the (summed) dipole moment self.wnorms = np.sum(self.weights, axis=0)/np.sum(self.weights) #provides a normalization factor for each state, ensuring that the weights are comparable across states + def read_data_direct_osc(self, excitation_energies_cm, oscillator_stregths): + + self.infile = "Test_Filename" #stores the filename + self.time = datetime.datetime.now() #records the current date and time + + self.exc = excitation_energies_cm*0.0001239841984 #assign the provided excitation energies directly to the instance variable, converting to eV. + + self.trans = abs((3*oscillator_stregths)/(2*(self.exc/27.211396))) + + self.weights = self.exc*self.trans #calculate the weight for each transition as the product of excitation energy and the (summed) dipole moment + self.wnorms = np.sum(self.weights, axis=0)/np.sum(self.weights) #provides a normalization factor for each state, ensuring that the weights are comparable across states + def read_data(self, infile): """Reads and parses input data from given input file.""" From d2ce1ee5af9678bc370dc6286cf70e47d5d0e585 Mon Sep 17 00:00:00 2001 From: Fel1-x <150053138+Fel1-x@users.noreply.github.com> Date: Mon, 17 Mar 2025 13:50:27 +0000 Subject: [PATCH 2/3] cleaned up rep_resampler, ensuring eV units are used and constants are defined. --- repsample_acetylcall.py | 3 ++- src/pyneapples/rep_sampler_2d.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/repsample_acetylcall.py b/repsample_acetylcall.py index e608f6d..fdc7722 100644 --- a/repsample_acetylcall.py +++ b/repsample_acetylcall.py @@ -30,10 +30,11 @@ oscillator_strengths_array = np.array(oscillator_strengths) excitation_energies_cm_array = np.array(excitation_energies_cm) +excitation_energies_ev_array = excitation_energies_cm_array * 0.0001239841984 MYGEOM = rstd.GeomReduction(2000, 3, 5, 1000, 8, 16, weighted=True, pdfcomp = "KLdiv", intweights=False, verbose=False, dim1=False) #create an instance of GeomReduction with specified parameters: 500 samples, 3 states, 20 representative molecules, 100 cycles, 1 core, 1 job, without weighting, using KL divergence for PDF comparison, no integer weights, and verbose off np.random.seed(42) #set the seed for reproducibility -MYGEOM.read_data_direct_osc(excitation_energies_cm_array, oscillator_strengths_array) #directly feed the generated data into the GeomReduction instance +MYGEOM.read_data_direct_osc(excitation_energies_ev_array, oscillator_strengths_array) #directly feed the generated data into the GeomReduction instance MYGEOM.reduce_geoms() #start the geometry reduction process to select representative geometries diff --git a/src/pyneapples/rep_sampler_2d.py b/src/pyneapples/rep_sampler_2d.py index f3402c8..03dd4d4 100644 --- a/src/pyneapples/rep_sampler_2d.py +++ b/src/pyneapples/rep_sampler_2d.py @@ -212,14 +212,15 @@ def read_data_direct(self, excitation_energies, transition_dipole_moments_x, tra self.weights = self.exc*self.trans #calculate the weight for each transition as the product of excitation energy and the (summed) dipole moment self.wnorms = np.sum(self.weights, axis=0)/np.sum(self.weights) #provides a normalization factor for each state, ensuring that the weights are comparable across states - def read_data_direct_osc(self, excitation_energies_cm, oscillator_stregths): + def read_data_direct_osc(self, excitation_energies, oscillator_stregths): + + evs_in_au = 27.211396 # Define the converion factor from electronvolts to atomic units self.infile = "Test_Filename" #stores the filename + self.exc = excitation_energies # Assign excitation energies in eV units self.time = datetime.datetime.now() #records the current date and time - self.exc = excitation_energies_cm*0.0001239841984 #assign the provided excitation energies directly to the instance variable, converting to eV. - - self.trans = abs((3*oscillator_stregths)/(2*(self.exc/27.211396))) + self.trans = abs((3*oscillator_stregths)/(2*(self.exc/evs_in_au))) # Calculate transition dipole moment scaler value (as above) using energy in a.u. self.weights = self.exc*self.trans #calculate the weight for each transition as the product of excitation energy and the (summed) dipole moment self.wnorms = np.sum(self.weights, axis=0)/np.sum(self.weights) #provides a normalization factor for each state, ensuring that the weights are comparable across states From 18be30c414bdf4237dc6ed545eaba187be8dc0b6 Mon Sep 17 00:00:00 2001 From: Fel1-x <150053138+Fel1-x@users.noreply.github.com> Date: Sat, 22 Mar 2025 11:15:26 +0000 Subject: [PATCH 3/3] Update src/pyneapples/rep_sampler_2d.py Co-authored-by: Daniel Hollas --- src/pyneapples/rep_sampler_2d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyneapples/rep_sampler_2d.py b/src/pyneapples/rep_sampler_2d.py index 03dd4d4..08f2209 100644 --- a/src/pyneapples/rep_sampler_2d.py +++ b/src/pyneapples/rep_sampler_2d.py @@ -214,7 +214,7 @@ def read_data_direct(self, excitation_energies, transition_dipole_moments_x, tra def read_data_direct_osc(self, excitation_energies, oscillator_stregths): - evs_in_au = 27.211396 # Define the converion factor from electronvolts to atomic units + evs_in_au = 27.211396 # Conversion factor from electronvolts to atomic units self.infile = "Test_Filename" #stores the filename self.exc = excitation_energies # Assign excitation energies in eV units