Everything that comes after the "for" loop line must be indented, otherwise Python doesn't know which part of the script that should be looped over.
So the correct syntax is
for i in [1,2,3]:
print i
where you now have
The point of my example was not that you should include it, but to demonstrate the concept of indentation.
What you need is to indent all the lines in your script that should be executed inside the loop. Specifically:
from NanoLanguage import *
#read in the old configuration
device_configuration = nlread("lih2li.nc",DeviceConfiguration)[0]
calculator = device_configuration.calculator()
# Define sample biases
voltage_list = numpy.linspace(0.1,1.0,10)
for voltage in voltage_list:
# Set the calculator and use the old scf state as starting input.
device_configuration.setCalculator(
calculator(electrode_voltages=(-0.5*voltage,0.5*voltage)*Volt ),
initial_state=device_configuration
)
#Analysis
filename = 'lih2li.nc'
electrostatic_potential = ElectrostaticDifferencePotential(device_configuration)
nlsave(filename, electrostatic_potential, object_id='pot'+str(voltage))
transmission_spectrum = TransmissionSpectrum(
configuration=device_configuration,
energies=numpy.linspace(-5,5,200)*eV,
)
nlsave(filename, transmission_spectrum,object_id='trans'+str(voltage))
molecular_energy_spectrum = MolecularEnergySpectrum(
configuration=device_configuration,
energy_zero_parameter=FermiLevel,
projection_list=ProjectionList([Hydrogen])
)
nlsave(filename, molecular_energy_spectrum,object_id='mpsh'+str(voltage))
instead of
from NanoLanguage import *
#read in the old configuration
device_configuration = nlread("lih2li.nc",DeviceConfiguration)[0]
calculator = device_configuration.calculator()
# Define sample biases
voltage_list = numpy.linspace(0.1,1.0,10)
for voltage in voltage_list:
# Set the calculator and use the old scf state as starting input.
device_configuration.setCalculator(
calculator(electrode_voltages=(-0.5*voltage,0.5*voltage)*Volt ),
initial_state=device_configuration
)
#Analysis
filename = 'lih2li.nc'
electrostatic_potential = ElectrostaticDifferencePotential(device_configuration)
nlsave(filename, electrostatic_potential, object_id='pot'+str(voltage))
transmission_spectrum = TransmissionSpectrum(
configuration=device_configuration,
energies=numpy.linspace(-5,5,200)*eV,
)
nlsave(filename, transmission_spectrum,object_id='trans'+str(voltage))
molecular_energy_spectrum = MolecularEnergySpectrum(
configuration=device_configuration,
energy_zero_parameter=FermiLevel,
projection_list=ProjectionList([Hydrogen])
)
nlsave(filename, molecular_energy_spectrum,object_id='mpsh'+str(voltage))
Note the difference!
PS: When posting code, use the "code" tags to make it more readable, and to maintain proper formatting.