Author Topic: problems about the calculation max steps in the restarting calculation  (Read 3362 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 quantumwise staff:           Recently i confronted a convergence problems in MoS2 ,so i referred to the forum  and increase the max steps ,the problem is as follows: if i don't restart from the convergened state ,that is i calculate it from zero bias ,here is my max steps setting.
Code
#----------------------------------------
# Iteration Control Settings
#----------------------------------------
left_electrode_iteration_control_parameters = IterationControlParameters(
    max_steps=500,
    )

right_electrode_iteration_control_parameters = IterationControlParameters(
    max_steps=500,
    )

device_iteration_control_parameters = IterationControlParameters(
    damping_factor=0.31,
    max_steps=2000,
    number_of_history_steps=10,
    )

#----------------------------------------
# Poisson Solver Settings
#----------------------------------------
left_electrode_poisson_solver = FastFourier2DSolver(
    boundary_conditions=[[PeriodicBoundaryCondition,PeriodicBoundaryCondition],
                         [PeriodicBoundaryCondition,PeriodicBoundaryCondition],
                         [PeriodicBoundaryCondition,PeriodicBoundaryCondition]]
    )

right_electrode_poisson_solver = FastFourier2DSolver(
    boundary_conditions=[[PeriodicBoundaryCondition,PeriodicBoundaryCondition],
                         [PeriodicBoundaryCondition,PeriodicBoundaryCondition],
                         [PeriodicBoundaryCondition,PeriodicBoundaryCondition]]
    )

#----------------------------------------
# Contour Integral Settings
#----------------------------------------
contour_parameters = DoubleContourIntegralParameters(
    real_axis_infinitesimal=1e-06*Rydberg,
    real_axis_point_density=0.02*eV,
    integral_lower_bound=50.0*eV,
    )

#----------------------------------------
# Electrode Calculators
#----------------------------------------
left_electrode_calculator = LCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    iteration_control_parameters=left_electrode_iteration_control_parameters,
    poisson_solver=left_electrode_poisson_solver,
    )

right_electrode_calculator = LCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    iteration_control_parameters=right_electrode_iteration_control_parameters,
    poisson_solver=right_electrode_poisson_solver,
    )

#----------------------------------------
# Device Calculator
#----------------------------------------
calculator = DeviceLCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    iteration_control_parameters=device_iteration_control_parameters,
    contour_parameters=contour_parameters,
    electrode_calculators=
        [left_electrode_calculator, right_electrode_calculator],
    )

device_configuration.setCalculator(calculator)

# -------------------------------------------------------------
# Initial State
# -------------------------------------------------------------
initial_spin = InitialSpin(scaled_spins=[0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, -1.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, -1.0, 0.0, 0.0])
device_configuration.setCalculator(
    calculator,
    initial_spin=initial_spin,
)
device_configuration.update()
nlsave('CONFIG.nc', device_configuration)
nlprint(device_configuration)

# -------------------------------------------------------------
# IV Curve
# -------------------------------------------------------------
calculator=device_configuration.calculator()

biases = [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)
My calculation is slowly converged in the step =635 ,
Code
350627:| 615 E = -447.349 dE =  4.819839e-04 dH =  2.388363e-04
350846:| 616 E =  -447.35 dE =  9.950206e-04 dH =  8.781832e-04
351065:| 617 E =  -447.35 dE =  1.495225e-04 dH =  1.050059e-03
351284:| 618 E = -447.349 dE =  7.514605e-04 dH =  2.417407e-04
351503:| 619 E = -447.349 dE =  8.285889e-05 dH =  1.792596e-04
351722:| 620 E = -447.348 dE =  6.273245e-04 dH =  1.333994e-04
351941:| 621 E = -447.348 dE =  4.864245e-04 dH =  3.458751e-04
352160:| 622 E = -447.348 dE =  1.074768e-04 dH =  2.376046e-04
352379:| 623 E = -447.349 dE =  6.705824e-04 dH =  3.217824e-04
352598:| 624 E = -447.348 dE =  6.934614e-04 dH =  3.254210e-04
352817:| 625 E = -447.348 dE =  3.242197e-04 dH =  2.692547e-04
353036:| 626 E = -447.348 dE =  1.095985e-04 dH =  1.103893e-04
353255:| 627 E = -447.349 dE =  7.666417e-04 dH =  1.624413e-04
353474:| 628 E = -447.349 dE =  1.769304e-05 dH =  4.870540e-04
353693:| 629 E = -447.348 dE =  8.042218e-04 dH =  1.483390e-04
353912:| 630 E = -447.348 dE =  1.963235e-06 dH =  2.435271e-04
354131:| 631 E = -447.349 dE =  6.199732e-04 dH =  5.196899e-04
354350:| 632 E = -447.348 dE =  5.375404e-04 dH =  1.000946e-04
354569:| 633 E = -447.348 dE =  1.350441e-05 dH =  1.004250e-04
354788:| 634 E = -447.348 dE =  1.106934e-04 dH =  1.264113e-04
355007:| 635 E = -447.348 dE =  3.390452e-05 dH =  9.519258e-05
355462:|   0 E = -428.204 dE =  1.917845e+01 dH =  1.470380e-01
355681:|   1 E = -439.981 dE =  1.177661e+01 dH =  3.916571e+00
355900:|   2 E = -445.977 dE =  5.996319e+00 dH =  7.775032e-01
356119:|   3 E = -446.527 dE =  5.499668e-01 dH =  2.842024e-01
356338:|   4 E = -446.857 dE =  3.301646e-01 dH =  8.742580e-02
356557:|   5 E = -446.732 dE =  1.250417e-01 dH =  1.973932e-01
356776:|   6 E = -446.928 dE =  1.960541e-01 dH =  8.639483e-02
356995:|   7 E = -446.951 dE =  2.286883e-02 dH =  8.455163e-02
357214:|   8 E = -447.205 dE =  2.537133e-01 dH =  9.177060e-02
357433:|   9 E = -447.073 dE =  1.319129e-01 dH =  7.540765e-02
357652:|  10 E = -447.258 dE =  1.854489e-01 dH =  5.404163e-02
357871:|  11 E = -447.261 dE =  3.214866e-03 dH =  8.341868e-02
358090:|  12 E = -447.239 dE =  2.249815e-02 dH =  6.084702e-02
358309:|  13 E = -447.096 dE =  1.428855e-01 dH =  5.987770e-02
358528:|  14 E = -447.068 dE =  2.819535e-02 dH =  4.608637e-02
358747:|  15 E = -447.118 dE =  5.013750e-02 dH =  8.704623e-02
358966:|  16 E = -447.188 dE =  6.975315e-02 dH =  6.939250e-02
359185:|  17 E = -447.285 dE =  9.755813e-02 dH =  1.863129e-01
but when i  set  same max step in another restarting py ,
Code
#----------------------------------------
# Iteration Control Settings
#----------------------------------------
left_electrode_iteration_control_parameters = IterationControlParameters(
    max_steps=1000,
    )

right_electrode_iteration_control_parameters = IterationControlParameters(
    max_steps=1000,
    )

device_iteration_control_parameters = IterationControlParameters(
    damping_factor=0.36,
    max_steps=2000,
    number_of_history_steps=8,
    )

#----------------------------------------
# Poisson Solver Settings
#----------------------------------------
left_electrode_poisson_solver = FastFourier2DSolver(
    boundary_conditions=[[PeriodicBoundaryCondition,PeriodicBoundaryCondition],
                         [PeriodicBoundaryCondition,PeriodicBoundaryCondition],
                         [PeriodicBoundaryCondition,PeriodicBoundaryCondition]]
    )

right_electrode_poisson_solver = FastFourier2DSolver(
    boundary_conditions=[[PeriodicBoundaryCondition,PeriodicBoundaryCondition],
                         [PeriodicBoundaryCondition,PeriodicBoundaryCondition],
                         [PeriodicBoundaryCondition,PeriodicBoundaryCondition]]
    )

#----------------------------------------
# Contour Integral Settings
#----------------------------------------
contour_parameters = DoubleContourIntegralParameters(
    real_axis_infinitesimal=1e-06*Rydberg,
    real_axis_point_density=0.02*eV,
    integral_lower_bound=50.0*eV,
    )

#----------------------------------------
# Electrode Calculators
#----------------------------------------
left_electrode_calculator = LCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    iteration_control_parameters=left_electrode_iteration_control_parameters,
    poisson_solver=left_electrode_poisson_solver,
    )

right_electrode_calculator = LCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    iteration_control_parameters=right_electrode_iteration_control_parameters,
    poisson_solver=right_electrode_poisson_solver,
    )

#----------------------------------------
# Device Calculator
#----------------------------------------
calculator = DeviceLCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    iteration_control_parameters=device_iteration_control_parameters,
    contour_parameters=contour_parameters,
    electrode_calculators=
        [left_electrode_calculator, right_electrode_calculator],
    )

device_configuration.setCalculator(calculator)

# -------------------------------------------------------------
# Initial State
# -------------------------------------------------------------
initial_spin = InitialSpin(scaled_spins=[0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0])
device_configuration.setCalculator(
    calculator,
    initial_spin=initial_spin,
)
device_configuration = nlread("ivcurve_selfconsistent_configurations_bias_-0.1.nc")[0]
device_configuration.update(force_restart=True)
nlsave('CONFIG.nc', device_configuration)
nlprint(device_configuration)

# -------------------------------------------------------------
# IV Curve
# -------------------------------------------------------------
calculator=device_configuration.calculator()

biases = [-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)
it stopped in the step=499 (i should mentioned that in the previous V= -0.1,i used max steps as 500) ,so i wonder if it is because the restarting for -0.1 make the new max step =2000 invalid ,can anyone explain about it ?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Just declaring the max_steps has no effect. You also need to use the parameter class "device_iteration_control_parameters" in the calculator actually used. Keep in mind your script is code, just setting a=1 doesn't do anything if you don't use a for anything. When you restart at higher bias, depending on HOW you do it, it will use the calculator of the zero bias if you only change the electrode voltages.

Offline ATK-user-zuox

  • Heavy QuantumATK user
  • ***
  • Posts: 26
  • Country: cn
  • Reputation: 1
    • View Profile
I used my original job and found that my change of
Code
#----------------------------------------
# Iteration Control Settings
#----------------------------------------
left_electrode_iteration_control_parameters = IterationControlParameters(
    max_steps=1000,
    )

right_electrode_iteration_control_parameters = IterationControlParameters(
    max_steps=1000,
    )

device_iteration_control_parameters = IterationControlParameters(
    damping_factor=0.36,
    max_steps=2000,
    number_of_history_steps=8,
    )
is effective in my calculation and  my calculation accelerates to convergence because of the large damping_factor ,but the  max_steps is not changed .so i am quite confused .As you said , if i  redefine the  Iteration Control Settings in the I-V block ,will it be effective on the max_steps?
Code
# -------------------------------------------------------------
# IV Curve
# -------------------------------------------------------------
#----------------------------------------
# Iteration Control Settings
#----------------------------------------
left_electrode_iteration_control_parameters = IterationControlParameters(
    max_steps=3000,
    )

right_electrode_iteration_control_parameters = IterationControlParameters(
    max_steps=3000,
    )

device_iteration_control_parameters = IterationControlParameters(
    damping_factor=0.25,
    max_steps=3000,
    number_of_history_steps=12,
    )

calculator=device_configuration.calculator()

biases = [-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)

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
No, because your variable device_iteration_control_parameters is only defined, never used by the calculator.

You need create a new calculator by cloning the old one,

new_calculator = calculator(iteration_control_parameters=device_iteration_control_parameters)

and then use this in the bias loop.