@@ -105,42 +105,39 @@ def get_energy(atnum, nelec, ip, datafile):
105
105
106
106
Returns
107
107
-------
108
- float
109
- Ground state energy of the species (in Ha).
108
+ float or None
109
+ Ground state energy of the species (in Ha). Returns None if data is unavailable.
110
110
111
111
Notes
112
- -----
113
- Dianion species get a default energy value of None. For anions with charge=-1, the energy is computed
114
- as E_anion = E_neutral - IP_anion, where E_neutral is the ground state energy of the neutral species
115
- and IP_anion is the ionization potential of the anion. The IP_anion is obtained from the conceptual-DFT
116
- data in the file data/c6cp04533b1.csv.
117
-
112
+ -----
113
+ - Dianion species (charge = -2) return None.
114
+ - Anion energy (charge = -1) is computed as:
115
+ :math:`E_{anion} = E_{neutral} - IP_{anion}`
116
+ where :math:`IP_{anion}` is obtained from the conceptual-DFT data in the file data/c6cp04533b1.csv.
118
117
"""
119
- # Set an energy default value in case there isn't available NIST data
120
- energy = None
118
+ default_energy = None
121
119
charge = atnum - nelec
122
120
hdf5_path = os .path .join (MODULE_DATAPATH , datafile )
123
121
124
- # Load NIST atomic spectra database data (contains neutral and cationic species).
122
+ # Return None for dianions (charge = -2)
125
123
if charge == - 2 :
126
- return energy
127
-
128
- if charge == - 1 :
129
- nelec = atnum
124
+ return default_energy
125
+
126
+ # Load NIST atomic spectra database data (contains neutral and cationic species).
127
+ # For anions, load data for the neutral species (nelec = atnum)
128
+ nelec = nelec if charge != - 1 else atnum
130
129
spectra_data = load_nist_spectra_data (atnum , nelec , hdf5_path )
131
130
energies = spectra_data ["energy" ]
132
131
133
- # Energy for neutral or cationic species
132
+ # Return energy (in Hartree) for neutral and cationic species (charge ≥ 0)
134
133
if charge >= 0 :
135
- # energies = spectra_data["energy"]
136
- # Convert energy to Hartree from cm^{-1} if available
137
- return energies [0 ] / CMINV if len (energies ) != 0 else energy
134
+ return energies [0 ] / CMINV if len (energies ) != 0 else default_energy
135
+
136
+ # Compute anion energy (charge = -1), ensuring ip is not zero or None
137
+ if charge == - 1 and ip not in [None , 0 ]:
138
+ return (energies [0 ] / CMINV - ip ) if len (energies ) != 0 else default_energy
138
139
139
- # Energy for anions with charge=-1
140
- elif charge == - 1 and ip not in [None , 0 ]: # check IP is not zero or None
141
- # neutral_energy = load_nist_spectra_data(atnum, atnum, hdf5_path)["energy"]
142
- # Convert energy to Hartree from cm^{-1} if available
143
- return (energies [0 ] / CMINV - ip ) if len (energies ) != 0 else energy
140
+ return default_energy
144
141
145
142
146
143
def run (elem , charge , mult , nexc , dataset , datapath ):
@@ -203,26 +200,7 @@ def run(elem, charge, mult, nexc, dataset, datapath):
203
200
colid = table_etas [0 ].index (str (charge ))
204
201
eta = float (table_etas [atnum ][colid ]) * EV if len (table_etas [atnum ][colid ]) > 1 else None
205
202
206
- # # Get the ground state energy from database_beta_1.3.0.h5.
207
- # # Set an energy default value since there is no data for anions in database_beta_1.3.0.h5.
208
- # energy = None
209
- # h5path = os.path.join(MODULE_DATAPATH, "database_beta_1.3.0.h5")
210
- # if charge >= 0: # neutral or cationic species
211
- # spectra_data = load_nist_spectra_data(atnum, nelec, h5path)
212
- # energies = spectra_data["energy"]
213
- # # Convert energy to Hartree from cm^{-1} if available
214
- # energy = energies[0] / CMINV if len(energies) != 0 else energy
215
-
216
- # # Compute the ground state energy for anions with charge=-1
217
- # # Use the ground state energy of the neutral species from database_beta_1.3.0.h5
218
- # # and subtract the ionization potential of the anion from the conceptual-DFT data c6cp04533b1.csv
219
- # # This is: E_anion = E_neutral - IP_anion.
220
- # # This procedure does not work if there is no GS data for the neutral species, or if the anion's IP
221
- # # is zero or None.
222
- # if charge == -1 and ip not in [None, 0]: # check IP is not zero or None
223
- # neutral_energy = load_nist_spectra_data(atnum, atnum, h5path)["energy"]
224
- # # Convert energy to Hartree from cm^{-1} if available
225
- # energy = (neutral_energy[0] / CMINV - ip) if len(neutral_energy) != 0 else energy
203
+ # Get the ground state energy from NIST database_beta_1.3.0.h5.
226
204
energy = get_energy (atnum , nelec , ip , "database_beta_1.3.0.h5" )
227
205
228
206
# Return Species instance
0 commit comments