Verified Commit 1f6bde62 authored by Adel Kara Slimane's avatar Adel Kara Slimane
Browse files

Update energy operator test to new class names

parent c67a8d1b
Pipeline #35059 failed with stages
in 22 minutes and 57 seconds
......@@ -78,22 +78,22 @@ def test_energy_operator(show_progress=False):
builder, lat, added_cells = make_system()
syst = builder.finalized()
hamil_current_div_op = tkwant.operator.energy.CurrentDivergence(syst, where=[lat(0)], baseOperator='hamiltonian')
kin_current_div_op = tkwant.operator.energy.CurrentDivergence(syst, where=[lat(0)], baseOperator='kinetic+')
hamil_current_div_op = tkwant.operator.EnergyCurrentDivergence(syst, where=[lat(0)], baseOperator='hamiltonian')
kin_current_div_op = tkwant.operator.EnergyCurrentDivergence(syst, where=[lat(0)], baseOperator='kinetic+')
hamil_density_op = tkwant.operator.energy.Density(syst, where=[lat(0)], baseOperator='hamiltonian')
kin_density_op = tkwant.operator.energy.Density(syst, where=[lat(0)], baseOperator='kinetic+')
hamil_density_op = tkwant.operator.EnergyDensity(syst, where=[lat(0)], baseOperator='hamiltonian')
kin_density_op = tkwant.operator.EnergyDensity(syst, where=[lat(0)], baseOperator='kinetic+')
hamil_source_op = tkwant.operator.energy.Source(syst, where=[lat(0)], baseOperator='hamiltonian')
kin_source_op = tkwant.operator.energy.Source(syst, where=[lat(0)], baseOperator='kinetic+')
hamil_source_op = tkwant.operator.EnergySource(syst, where=[lat(0)], baseOperator='hamiltonian')
kin_source_op = tkwant.operator.EnergySource(syst, where=[lat(0)], baseOperator='kinetic+')
heat_current_0_op = tkwant.operator.energy.LeadHeatCurrent(syst, chemical_potential=μL, added_lead_sites=added_cells[0])
heat_current_1_op = tkwant.operator.energy.LeadHeatCurrent(syst, chemical_potential=μR, added_lead_sites=added_cells[1])
heat_current_0_op = tkwant.operator.LeadHeatCurrent(syst, chemical_potential=μL, added_lead_sites=added_cells[0])
heat_current_1_op = tkwant.operator.LeadHeatCurrent(syst, chemical_potential=μR, added_lead_sites=added_cells[1])
# Occupation, for each lead
occupation = [None] * len(syst.leads)
occupation[0] = tkwant.manybody.make_occupation(chemical_potential=μL, temperature=TL)
occupation[1] = tkwant.manybody.make_occupation(chemical_potential=μR, temperature=TR)
occupation[0] = tkwant.manybody.lead_occupation(chemical_potential=μL, temperature=TL)
occupation[1] = tkwant.manybody.lead_occupation(chemical_potential=μR, temperature=TR)
# Initialize the solver
solver = tkwant.manybody.State(syst, tmax, occupation, params={'ε0': ε0, 'Δε': Δε})
......@@ -134,24 +134,25 @@ def test_energy_operator(show_progress=False):
if am_master() and show_progress:
print("Progress = {:.1f} %".format(time / tmax * 100))
for time_index in range(len(times)):
if time_index < 2 or time_index >= len(times) - 2:
dt_hamil_density.append(0.)
dt_kin_density.append(0.)
else:
fm2 = hamil_density[time_index - 2]
fm1 = hamil_density[time_index - 1]
fp1 = hamil_density[time_index + 1]
fp2 = hamil_density[time_index + 2]
dt_hamil_density.append((fm2 - 8 * fm1 + 8 * fp1 - fp2) / (12 * dt))
fm2 = kin_density[time_index - 2]
fm1 = kin_density[time_index - 1]
fp1 = kin_density[time_index + 1]
fp2 = kin_density[time_index + 2]
dt_kin_density.append((fm2 - 8 * fm1 + 8 * fp1 - fp2) / (12 * dt))
if am_master():
for time_index in range(len(times)):
if time_index < 2 or time_index >= len(times) - 2:
dt_hamil_density.append(0.)
dt_kin_density.append(0.)
else:
fm2 = hamil_density[time_index - 2]
fm1 = hamil_density[time_index - 1]
fp1 = hamil_density[time_index + 1]
fp2 = hamil_density[time_index + 2]
dt_hamil_density.append((fm2 - 8 * fm1 + 8 * fp1 - fp2) / (12 * dt))
fm2 = kin_density[time_index - 2]
fm1 = kin_density[time_index - 1]
fp1 = kin_density[time_index + 1]
fp2 = kin_density[time_index + 2]
dt_kin_density.append((fm2 - 8 * fm1 + 8 * fp1 - fp2) / (12 * dt))
n = len(times) - 2
assert_allclose(hamil_current_div[2:n], correct_hamil_current_div, rtol=1E-4)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment