Author Topic: How to save selfconsistent_configurations for every voltage  (Read 3417 times)

0 Members and 1 Guest are viewing this topic.

Offline ATK-user-zuox

  • Heavy QuantumATK user
  • ***
  • Posts: 26
  • Country: cn
  • Reputation: 1
    • View Profile
Dear sir:        Recently i tested to  restart I-V calculations from a checkpoint . i learned from http://quantumwise.com/forum/index.php?topic=3306.msg15142#msg15142 andhttp://quantumwise.com/forum/index.php?topic=1358.msg9062#msg9062 about how to restart a suspended job.i modify the code as
Code
# -------------------------------------------------------------
# IV Curve
# -------------------------------------------------------------
calculator=device_configuration.calculator()

biases = [0.000000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000,
          0.600000, 0.700000, 0.800000, 0.900000, 1.000000]*Volt
for bias in biases:
    calculator=calculator(
            electrode_voltages=(bias/2, -bias/2))

    device_configuration.setCalculator(
          calculator(),
          initial_state=device_configuration)
    device_configuration.update()
    nlsave("ivcurve_selfconsistent_configurations.nc", device_configuration)
    
#----------------------------------------
# Transmission spectrum
#----------------------------------------
configurations = nlread('ivcurve_selfconsistent_configurations.nc', DeviceConfiguration)
     for device_configuration in configurations:
         transmission_spectrum = TransmissionSpectrum(
             configuration=device_configuration,
             energies=numpy.linspace(-2,2,201)*eV,
             kpoints=MonkhorstPackGrid(4, 4),
             energy_zero_parameter=AverageFermiLevel,
             infinitesimal=1e-06*eV,
             self_energy_calculator=RecursionSelfEnergy(),
             )
         nlsave("TS_analysis.nc", transmission_spectrum)
         nlprint(transmission_spectrum)
. So here is my idea: For the initial calculation script(not restaring script) i want to use "nlsave" statement to make a new file for each converged bias and calculate the transmission spectrum for each bias using each converged bias(i want to exactly know output bias file and restart from it ), my problem is : How to modify the above code in the I-V and transmission module  to realise the these two underlined functions.

Offline Jess Wellendorff

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 933
  • Country: dk
  • Reputation: 29
    • View Profile
Re: How to save selfconsistent_configurations for every voltage
« Reply #1 on: January 14, 2016, 09:22 »
Perhaps this code is what you need:
Code
# -------------------------------------------------------------
# IV Curve
# -------------------------------------------------------------
calculator = device_configuration.calculator()

biases = [0.000000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000,
          0.600000, 0.700000, 0.800000, 0.900000, 1.000000]*Volt

files = []
for bias in biases:
    myfile = "iv_%.3fV" % bias
    files.append(myfile)
    
    calculator=calculator(
            electrode_voltages=(bias/2, -bias/2))
    device_configuration.setCalculator(
          calculator(),
          initial_state=device_configuration)
    device_configuration.update()
    nlsave(myfile, device_configuration)

#----------------------------------------
# Transmission spectrum
#----------------------------------------
for myfile in files:
    device_configuration = nlread(myfile, DeviceConfiguration)[0]

    transmission_spectrum = TransmissionSpectrum(
        configuration=device_configuration,
        energies=numpy.linspace(-2,2,201)*eV,
        kpoints=MonkhorstPackGrid(4, 4),
        energy_zero_parameter=AverageFermiLevel,
        infinitesimal=1e-06*eV, 
        self_energy_calculator=RecursionSelfEnergy(),
        )
    nlsave(myfile, transmission_spectrum)  
    nlprint(transmission_spectrum)

Offline ATK-user-zuox

  • Heavy QuantumATK user
  • ***
  • Posts: 26
  • Country: cn
  • Reputation: 1
    • View Profile
Re: How to save selfconsistent_configurations for every voltage
« Reply #2 on: January 17, 2016, 13:14 »
Thanks for your kind reply , i whill check  it  tonight .I have already  solved  it in another way ,the code is :
Code
# -------------------------------------------------------------
# IV Curve
# -------------------------------------------------------------
calculator=device_configuration.calculator()

biases = [0.000000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000,
          0.600000, 0.700000, 0.800000, 0.900000, 1.000000]*Volt
for bias in biases:
    calculator=calculator(
            electrode_voltages=(bias/2, -bias/2))

    device_configuration.setCalculator(
          calculator(),
          initial_state=device_configuration)
    device_configuration.update()
    nlsave("ivcurve_selfconsistent_configurations_bias_%g.nc" % bias.inUnitsOf(Volt), device_configuration)
    
#----------------------------------------
# Transmission spectrum
#----------------------------------------
for bias in biases:
    configurations = nlread('ivcurve_selfconsistent_configurations_bias_%g.nc' % bias.inUnitsOf(Volt), DeviceConfiguration)
    for device_configuration in configurations:
           transmission_spectrum = TransmissionSpectrum(
               configuration=device_configuration,
               energies=numpy.linspace(-2,2,201)*eV,
               kpoints=MonkhorstPackGrid(4, 4),
               energy_zero_parameter=AverageFermiLevel,
               infinitesimal=1e-06*eV,
               self_energy_calculator=RecursionSelfEnergy(),
               )
           nlsave("TS_analysis.nc", transmission_spectrum)
           nlprint(transmission_spectrum)
This way to save the checkpoint is very helpful and it's easy to restart from the I-V converged state .Hope it could help the new learnrers.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: How to save selfconsistent_configurations for every voltage
« Reply #3 on: January 18, 2016, 10:20 »
That's a really excellent suggestion!!!