Skip to content

Commit

Permalink
rename for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
austingmhuang committed Oct 22, 2024
1 parent cd39f03 commit 8158291
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions demonstrations/tutorial_initial_state_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,21 @@ def cost_fn(param):
# And compare with how things go when you run it with the CISD initial state:


def cost_fn(param):
def cost_fn_cisd(param):
return circuit_VQE(param, initial_state=wf_cisd)


theta = jnp.array(jnp.zeros(len(excitations)))
delta_E, iteration = 10, 0
results_cisd = []
opt_state = opt.init(theta)
prev_energy = cost_fn(theta)
prev_energy = cost_fn_cisd(theta)

while abs(delta_E) > 1e-5:
gradient = jax.grad(cost_fn)(theta)
gradient = jax.grad(cost_fn_cisd)(theta)
updates, opt_state = opt.update(gradient, opt_state)
theta = optax.apply_updates(theta, updates)
new_energy = cost_fn(theta)
new_energy = cost_fn_cisd(theta)
delta_E = new_energy - prev_energy
prev_energy = new_energy
results_cisd.append(new_energy)
Expand Down

0 comments on commit 8158291

Please sign in to comment.