There are two ways to do it.
First of all, note that the "scf" is not a separate thing from the configuration. When you have run the self-consistent loop, the scf is stored on the configuration itself. So, if you want to use the approach to read the scf from the NC file, you would do like normal,
scf = nlread("energy.nc", BulkConfiguration)[-1]
...
bulk_configuration.setCalculator(calculator, initial_state=scf)
There is however a better way to do it in your case. Since you are looping in the same script, you can just remember the state for the next step, like so:
vector_a = [10.0, 0.0, 0.0]*Angstrom
vector_b = [0.0, 10.0, 0.0]*Angstrom
vector_c = [0.0, 0.0, 10.0]*Angstrom
lattice = UnitCell(vector_a, vector_b, vector_c)
# Define elements
elements = [Hydrogen]*2
scf = None # NEW
for dis in (a1,a2,a3,a4): # ai is the distance
fractional_coordinates = [[ 0. , 0. , 0. ],
[ 0. , 0. , dis]]
bulk_configuration = BulkConfiguration(
bravais_lattice=lattice,
elements=elements,
fractional_coordinates=fractional_coordinates
)
calculator = LCAOCalculator()
bulk_configuration.setCalculator(calculator, initial_state=scf) # NEW
bulk_configuration.update()
scf = bulk_configuration # NEW
nlsave('energy.nc', bulk_configuration)
total_energy = TotalEnergy(bulk_configuration)
nlsave('energy.nc', total_energy)
nlprint(total_energy)
Only 3 lines were modified, indicated by "NEW" above.