Skip to content

Commit

Permalink
Update excited script
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyed99 committed May 21, 2024
1 parent d147130 commit 6b7e5f5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
39 changes: 21 additions & 18 deletions src/hpc/contact_process_stat_exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,30 @@ def main():
time2 = time.time()
logger.info(f"Elapsed time: {time2 - time1} seconds")

np.savetxt(OUTPUT_PATH + f"eval_0_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
eigenvalues[0],
delimiter=',')
np.savetxt(OUTPUT_PATH + f"eval_1_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
eigenvalues[1],
delimiter=',')

evp_residual = (lindblad_hermitian @ eigentensors[1] - eigenvalues[1] * eigentensors[1]).norm()**2
logger.info(f"{eigenvalues=}")
logger.info(f"Eigensolver error for first excited state: {evp_residual}")

logger.info(f"First excited state energy per site: {eigenvalues[1]/L}")
logger.info(f"Norm of first excited state: {eigentensors[1].norm()**2}")

np.savetxt(OUTPUT_PATH + f"eval_0_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
np.array([eigenvalues[0]]),
fmt='%.6f')
np.savetxt(OUTPUT_PATH + f"eval_1_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
np.array([eigenvalues[1]]),
fmt='%.6f')

logger.info(
f"expVal_1, eval_1_als, eval_1: {compute_expVal(mps, lindblad_hermitian)}, {eigenvalues[1]}, {eigentensors[1].transpose(conjugate=True) @ lindblad_hermitian @ eigentensors[1]}"
)

mps = canonicalize_mps(eigentensors[1])
mps_dag = mps.transpose(conjugate=True)

# compute non-Hermitian part of mps
non_hermit_mps = (1 / 2) * (mps - mps_dag)
logger.info(f"The norm of the non-Hermitian part: {non_hermit_mps.norm()**2}")
logger.info(
f"expVal_1, eval_1_als, eval_1: {compute_expVal(mps, lindblad_hermitian)}, {eigenvalues[1]}, {mps_dag@lindblad_hermitian@mps}"
)

# compute Hermitian part of mps
hermit_mps = (1 / 2) * (mps + mps_dag)
Expand All @@ -85,23 +86,25 @@ def main():
logger.info(f"Particle number/site: {particle_nums}")
n_s = np.mean(particle_nums)
logger.info(f"Mean Particle number: {n_s}")
np.savetxt(OUTPUT_PATH + f"n_s_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt", n_s, delimiter=',')
np.savetxt(OUTPUT_PATH + f"n_s_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
np.array([n_s]),
fmt='%.6f')

if bond_dim == bond_dims[-1]:
logger.info(f"{bond_dim=}")
logger.info("Compute spectral gap of L†L for largest bond dimension")
spectral_gaps = abs(eigenvalues[1] - eigenvalues[0])
logger.info(f"{spectral_gaps=}")
np.savetxt(OUTPUT_PATH + f"spectral_gaps_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
spectral_gaps,
delimiter=',')
np.array([spectral_gaps]),
fmt='%.6f')

logger.info("Compute purity of state for largest bond dimension")
purities = compute_purity(mps)
logger.info(f"Purity: {purities}")
np.savetxt(OUTPUT_PATH + f"purities_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
purities,
delimiter=',')
np.array([purities]),
fmt='%.6f')

logger.info("Compute two-point correlation for largest bond dimension")
correlations = np.zeros(L - 1)
Expand All @@ -110,7 +113,7 @@ def main():
logger.info(f"{correlations=}")
np.savetxt(OUTPUT_PATH + f"correlations_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
correlations,
delimiter=',')
fmt='%.6f')

logger.info("Compute density-density correlation for largest bond dimension")
dens_dens_corr = np.zeros(L - 1)
Expand All @@ -119,14 +122,14 @@ def main():
logger.info(f"{dens_dens_corr=}")
np.savetxt(OUTPUT_PATH + f"dens_dens_corr_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
dens_dens_corr,
delimiter=',')
fmt='%.6f')

logger.info("Compute half-chain entanglement spectrum for largest bond dimension")
entanglement_spectrum = compute_entanglement_spectrum(mps)
logger.info(f"{entanglement_spectrum=}")
np.savetxt(OUTPUT_PATH + f"entanglement_spectrum_exc_L_{L}_D_{bond_dim}_O_{OMEGA}_{SLURM_ARRAY_JOB_ID}.txt",
entanglement_spectrum,
delimiter=',')
fmt='%.6f')

basis_0 = np.array([1, 0])
dark_state = construct_basis_mps(L, basis=[np.outer(basis_0, basis_0)] * L)
Expand Down
2 changes: 1 addition & 1 deletion src/hpc/jobs_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#SBATCH --cpus-per-task=24

# memory per CPU in MB (see also --mem)
#SBATCH --mem-per-cpu=4096
#SBATCH --mem-per-cpu=2048

# runtime in HH:MM:SS format (DAYS-HH:MM:SS format)
#SBATCH --time=3-00:00:00
Expand Down

0 comments on commit 6b7e5f5

Please sign in to comment.