@@ -149,9 +149,8 @@ def plane_wave_hamiltonian(grid, geometry,
149149 return jellium_op + external_potential
150150
151151
152- def fourier_transform (hamiltonian , n_dimensions , grid_length , length_scale ,
153- spinless ):
154- """Apply Fourier tranform to change hamiltonian in plane wave basis.
152+ def fourier_transform (hamiltonian , grid , spinless ):
153+ """Apply Fourier transform to change hamiltonian in plane wave basis.
155154
156155 .. math::
157156
@@ -160,27 +159,22 @@ def fourier_transform(hamiltonian, n_dimensions, grid_length, length_scale,
160159
161160 Args:
162161 hamiltonian: The hamiltonian in plane wave basis.
163- n_dimensions: An int giving the number of dimensions for the model.
164- grid_length: Int, the number of points in one dimension of the grid.
165- length_scale: Float, the real space length of a box dimension.
162+ grid: The discretization to use.
166163 spinless: Bool, whether to use the spinless model or not.
167164
168165 Returns:
169166 hamiltonian_t: An instance of the FermionOperator class.
170167 """
171168 return _fourier_transform_helper (hamiltonian = hamiltonian ,
172- n_dimensions = n_dimensions ,
173- grid_length = grid_length ,
174- length_scale = length_scale ,
169+ grid = grid ,
175170 spinless = spinless ,
176171 factor = + 1 ,
177172 vec_func_1 = momentum_vector ,
178173 vec_func_2 = position_vector )
179174
180175
181- def inverse_fourier_transform (hamiltonian , n_dimensions , grid_length ,
182- length_scale , spinless ):
183- """Apply Fourier tranform to change hamiltonian in plane wave dual basis.
176+ def inverse_fourier_transform (hamiltonian , grid , spinless ):
177+ """Apply Fourier transform to change hamiltonian in plane wave dual basis.
184178
185179 .. math::
186180
@@ -189,31 +183,23 @@ def inverse_fourier_transform(hamiltonian, n_dimensions, grid_length,
189183
190184 Args:
191185 hamiltonian: The hamiltonian in plane wave dual basis.
192- n_dimensions: An int giving the number of dimensions for the model.
193- grid_length: Int, the number of points in one dimension of the grid.
194- length_scale: Float, the real space length of a box dimension.
186+ grid: The discretization to use.
195187 spinless: Bool, whether to use the spinless model or not.
196188
197189 Returns:
198190 hamiltonian_t: An instance of the FermionOperator class.
199191 """
200192 return _fourier_transform_helper (hamiltonian = hamiltonian ,
201- n_dimensions = n_dimensions ,
202- grid_length = grid_length ,
203- length_scale = length_scale ,
193+ grid = grid ,
204194 spinless = spinless ,
205195 factor = - 1 ,
206196 vec_func_1 = position_vector ,
207197 vec_func_2 = momentum_vector )
208198
209199
210- def _fourier_transform_helper (hamiltonian , n_dimensions , grid_length ,
211- length_scale , spinless , factor ,
212- vec_func_1 , vec_func_2 ):
200+ def _fourier_transform_helper (hamiltonian , grid , spinless ,
201+ factor , vec_func_1 , vec_func_2 ):
213202 hamiltonian_t = None
214- grid = Grid (dimensions = n_dimensions ,
215- length = grid_length ,
216- scale = length_scale )
217203
218204 for term in hamiltonian .terms :
219205 transformed_term = None
@@ -227,7 +213,7 @@ def _fourier_transform_helper(hamiltonian, n_dimensions, grid_length,
227213 spin = None
228214 else :
229215 spin = ladder_operator [0 ] % 2
230- orbital = orbital_id (grid_length , indices_2 , spin )
216+ orbital = orbital_id (grid . length , indices_2 , spin )
231217 exp_index = factor * 1.0j * numpy .dot (vec_1 , vec_2 )
232218 if ladder_operator [1 ] == 1 :
233219 exp_index *= - 1.0
@@ -239,7 +225,7 @@ def _fourier_transform_helper(hamiltonian, n_dimensions, grid_length,
239225 else :
240226 new_basis += element
241227
242- new_basis *= numpy .sqrt (1.0 / float (grid_length ** n_dimensions ))
228+ new_basis *= numpy .sqrt (1.0 / float (grid . num_points () ))
243229
244230 if transformed_term is None :
245231 transformed_term = new_basis
0 commit comments