Author Topic: How to calculate the I-V (spin-down and spin-up ) with the 11.2?  (Read 10780 times)

0 Members and 1 Guest are viewing this topic.

Offline qnsyhanjiu

  • Heavy QuantumATK user
  • ***
  • Posts: 33
  • Reputation: 0
    • View Profile
Now,I calculate the I-V with 2008.10,every time I can calculate the I-V one ,for example,I calculate 0.1v-I,how to calculate many every time?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
If you really mean 11.2 (you wrote 2008.10 in the body of the post), have a look at http://quantumwise.com/publications/tutorials/mini-tutorials/98-i-v-curve-and-voltage-drop.

Offline 1ight0ne

  • Regular QuantumATK user
  • **
  • Posts: 23
  • Country: ru
  • Reputation: 0
    • View Profile
If you really mean 11.2 (you wrote 2008.10 in the body of the post), have a look at http://quantumwise.com/publications/tutorials/mini-tutorials/98-i-v-curve-and-voltage-drop.
Can I calculate I-V in this tutorial with spin polarization by using method in your post ? If i use this code
Code
# -------------------------------------------------------------
# TwoProbe configuration
# -------------------------------------------------------------

# -------------------------------------------------------------
# Left electrode
# -------------------------------------------------------------

# Set up lattice
vector_a = [6.0, 0.0, 0.0]*Angstrom
vector_b = [0.0, 6.0, 0.0]*Angstrom
vector_c = [0.0, 0.0, 8.7]*Angstrom
left_electrode_lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
left_electrode_elements = [Carbon, Carbon, Carbon]

# Define coordinates
left_electrode_coordinates = [[ 3.  ,  3.  ,  1.45],
                              [ 3.  ,  3.  ,  4.35],
                              [ 3.  ,  3.  ,  7.25]]*Angstrom

# Set up configuration
left_electrode = BulkConfiguration(
    bravais_lattice=left_electrode_lattice,
    elements=left_electrode_elements,
    cartesian_coordinates=left_electrode_coordinates
    )

# -------------------------------------------------------------
# Right electrode
# -------------------------------------------------------------

# Set up lattice
vector_a = [6.0, 0.0, 0.0]*Angstrom
vector_b = [0.0, 6.0, 0.0]*Angstrom
vector_c = [0.0, 0.0, 8.7]*Angstrom
right_electrode_lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
right_electrode_elements = [Carbon, Carbon, Carbon]

# Define coordinates
right_electrode_coordinates = [[ 3.  ,  3.  ,  1.45],
                               [ 3.  ,  3.  ,  4.35],
                               [ 3.  ,  3.  ,  7.25]]*Angstrom

# Set up configuration
right_electrode = BulkConfiguration(
    bravais_lattice=right_electrode_lattice,
    elements=right_electrode_elements,
    cartesian_coordinates=right_electrode_coordinates
    )

# -------------------------------------------------------------
# Central region
# -------------------------------------------------------------

# Set up lattice
vector_a = [6.0, 0.0, 0.0]*Angstrom
vector_b = [0.0, 6.0, 0.0]*Angstrom
vector_c = [0.0, 0.0, 34.8]*Angstrom
central_region_lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
central_region_elements = [Carbon, Carbon, Carbon, Carbon, Carbon, Carbon, Carbon, Carbon,
                           Carbon, Carbon, Carbon, Carbon]

# Define coordinates
central_region_coordinates = [[  3.  ,   3.  ,   1.45],
                              [  3.  ,   3.  ,   4.35],
                              [  3.  ,   3.  ,   7.25],
                              [  3.  ,   3.  ,  10.15],
                              [  3.  ,   3.  ,  13.05],
                              [  3.  ,   3.  ,  15.95],
                              [  3.  ,   3.  ,  18.85],
                              [  3.  ,   3.  ,  21.75],
                              [  3.  ,   3.  ,  24.65],
                              [  3.  ,   3.  ,  27.55],
                              [  3.  ,   3.  ,  30.45],
                              [  3.  ,   3.  ,  33.35]]*Angstrom

# Set up configuration
central_region = BulkConfiguration(
    bravais_lattice=central_region_lattice,
    elements=central_region_elements,
    cartesian_coordinates=central_region_coordinates
    )

device_configuration = DeviceConfiguration(
    central_region,
    [left_electrode, right_electrode]
    )

# -------------------------------------------------------------
# Calculator
# -------------------------------------------------------------
#----------------------------------------
# Exchange-Correlation
#----------------------------------------
exchange_correlation = LSDA.PZ

#----------------------------------------
# Numerical Accuracy Settings
#----------------------------------------
left_electrode_numerical_accuracy_parameters = NumericalAccuracyParameters(
    k_point_sampling=(1, 1, 100),
    )

right_electrode_numerical_accuracy_parameters = NumericalAccuracyParameters(
    k_point_sampling=(1, 1, 100),
    )

#----------------------------------------
# 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]]
    )

#----------------------------------------
# Electrode Calculators
#----------------------------------------
left_electrode_calculator = LCAOCalculator(
    exchange_correlation=exchange_correlation,
    numerical_accuracy_parameters=left_electrode_numerical_accuracy_parameters,
    poisson_solver=left_electrode_poisson_solver,
    )

right_electrode_calculator = LCAOCalculator(
    exchange_correlation=exchange_correlation,
    numerical_accuracy_parameters=right_electrode_numerical_accuracy_parameters,
    poisson_solver=right_electrode_poisson_solver,
    )

#----------------------------------------
# Device Calculator
#----------------------------------------
calculator = DeviceLCAOCalculator(
    exchange_correlation=exchange_correlation,
    electrode_calculators=
        [left_electrode_calculator, right_electrode_calculator],
    electrode_voltages=( 0.15*Volt, -0.15*Volt)
    )

for bias in [0., 0.1, 0.2, 0.3]*Volt:
#    device_configuration.setCalculator(calculator)
    device_configuration.setCalculator(
        calculator(electrode_voltages=(0.5*bias,-0.5*bias)),
        initial_state=device_configuration
    )

# -------------------------------------------------------------
# Initial State
# -------------------------------------------------------------
initial_spin = InitialSpin(scaled_spins=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
device_configuration.setCalculator(
    calculator,
    initial_spin=initial_spin,
)
device_configuration.update()
nlsave('C:/Users/Alexander/Documents/VNL_tmp/carbon_chain.nc', device_configuration)
nlprint(device_configuration)
I have some errors...

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Which errors?

Offline 1ight0ne

  • Regular QuantumATK user
  • **
  • Posts: 23
  • Country: ru
  • Reputation: 0
    • View Profile
Which errors?
# Warning: The provided initial state parameter has no pre-calculated data.  Proceeding without setting an initial state.  then i use this script
Code
01.# Define input and output NetCDF files here
02.scf_filename = "lih2li_iv_scf.nc"
03.analysis_filename = "lih2li_iv_analysis.nc"
04. 
05.# Read all configurations from NetCDF file 
06.configurations = nlread(scf_filename, DeviceConfiguration) 
07.biases = [float(conf.calculator().electrodeVoltages()[0]-conf.calculator().electrodeVoltages()[1]) for conf in configurations] 
08.configurations = [configurations[i] for i in numpy.argsort(biases)] 
09. 
10.# First compute the zero-bias potential 
11.for configuration in configurations: 
12.calculator = configuration.calculator()
13.bias = calculator.electrodeVoltages()[0]-calculator.electrodeVoltages()[1]
14. 
15.if float(bias)==0.: 
16.zero_bias_potential = ElectrostaticDifferencePotential(configuration) 
17.break 
18. 
19.for configuration in configurations: 
20. 
21.# For each one, extract the bias, 
22.calculator = configuration.calculator()
23.bias = calculator.electrodeVoltages()[0]-calculator.electrodeVoltages()[1]
24.# ... calculate and save the transmission spectrum, 
25.transmission_spectrum = TransmissionSpectrum( 
26.configuration=configuration, 
27.energies=numpy.linspace(-2,8,100)*eV, 
28.kpoints=MonkhorstPackGrid(1,1,1) 
29.) 
30.nlsave(analysis_filename, transmission_spectrum, object_id="Transmission %s" % bias) 
31.# Uncomment the line below if you want all transmission spectra in the log file 
32.#nlprint(transmission_spectrum) 
33. 
34.potential = ElectrostaticDifferencePotential(configuration) 
35. 
36.# Uncomment the line below if you want to save all potentials, and not just the voltage drops 
37.#nlsave(analysis_filename, potential, object_id="Potential %s" % bias) 
38. 
39.# Calculate and save the voltage drop (except for zero bias) 
40.if float(bias)!=0.: 
41.voltage_drop = potential - zero_bias_potential 
42.nlsave(analysis_filename, voltage_drop, object_id="Voltage drop %s" % bias) 
43. 
44.# Copy geometry to analysis file, for plotting 
45.geometry = nlread(scf_filename, DeviceConfiguration, read_state = False)[0] 
46.nlsave(analysis_filename, geometry)
and it calculate just one point and one transmission spectrum and show this error:
Code
Traceback (most recent call last):
  File "c:\temp\0674981154396043.py", line 44, in <module>
    voltage_drop = potential - zero_bias_potential
NameError: name 'zero_bias_potential' is not defined

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
The first thing is a warning, not an error, and can safely be ignored (unless it happens multiple times during the IV loop). It's because for the first bias point there is no lower bias point to start from. The second one is perhaps caused by the fact that there is no point with bias = 0 V in the NC file. You must always have that as a reference. Looking back to your script I can see why - you have lost the indentation, which is a crucial point in Python. Consider these two examples:
Code: python
for i in [1,2,3]:
    j = i+1
    print j
and
Code: python
for i in [1,2,3]:
    j = i+1
print j
You have the second version (which only prints 4), it should have been the first (which prints 2,3,4), and your code should have looked like:
Code: python
# -------------------------------------------------------------
# TwoProbe configuration
# -------------------------------------------------------------

# -------------------------------------------------------------
# Left electrode
# -------------------------------------------------------------

# Set up lattice
vector_a = [6.0, 0.0, 0.0]*Angstrom
vector_b = [0.0, 6.0, 0.0]*Angstrom
vector_c = [0.0, 0.0, 8.7]*Angstrom
left_electrode_lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
left_electrode_elements = [Carbon, Carbon, Carbon]

# Define coordinates
left_electrode_coordinates = [[ 3.  ,  3.  ,  1.45],
                              [ 3.  ,  3.  ,  4.35],
                              [ 3.  ,  3.  ,  7.25]]*Angstrom

# Set up configuration
left_electrode = BulkConfiguration(
    bravais_lattice=left_electrode_lattice,
    elements=left_electrode_elements,
    cartesian_coordinates=left_electrode_coordinates
    )

# -------------------------------------------------------------
# Right electrode
# -------------------------------------------------------------

# Set up lattice
vector_a = [6.0, 0.0, 0.0]*Angstrom
vector_b = [0.0, 6.0, 0.0]*Angstrom
vector_c = [0.0, 0.0, 8.7]*Angstrom
right_electrode_lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
right_electrode_elements = [Carbon, Carbon, Carbon]

# Define coordinates
right_electrode_coordinates = [[ 3.  ,  3.  ,  1.45],
                               [ 3.  ,  3.  ,  4.35],
                               [ 3.  ,  3.  ,  7.25]]*Angstrom

# Set up configuration
right_electrode = BulkConfiguration(
    bravais_lattice=right_electrode_lattice,
    elements=right_electrode_elements,
    cartesian_coordinates=right_electrode_coordinates
    )

# -------------------------------------------------------------
# Central region
# -------------------------------------------------------------

# Set up lattice
vector_a = [6.0, 0.0, 0.0]*Angstrom
vector_b = [0.0, 6.0, 0.0]*Angstrom
vector_c = [0.0, 0.0, 34.8]*Angstrom
central_region_lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
central_region_elements = [Carbon, Carbon, Carbon, Carbon, Carbon, Carbon, Carbon, Carbon,
                           Carbon, Carbon, Carbon, Carbon]

# Define coordinates
central_region_coordinates = [[  3.  ,   3.  ,   1.45],
                              [  3.  ,   3.  ,   4.35],
                              [  3.  ,   3.  ,   7.25],
                              [  3.  ,   3.  ,  10.15],
                              [  3.  ,   3.  ,  13.05],
                              [  3.  ,   3.  ,  15.95],
                              [  3.  ,   3.  ,  18.85],
                              [  3.  ,   3.  ,  21.75],
                              [  3.  ,   3.  ,  24.65],
                              [  3.  ,   3.  ,  27.55],
                              [  3.  ,   3.  ,  30.45],
                              [  3.  ,   3.  ,  33.35]]*Angstrom

# Set up configuration
central_region = BulkConfiguration(
    bravais_lattice=central_region_lattice,
    elements=central_region_elements,
    cartesian_coordinates=central_region_coordinates
    )

device_configuration = DeviceConfiguration(
    central_region,
    [left_electrode, right_electrode]
    )

# -------------------------------------------------------------
# Calculator
# -------------------------------------------------------------
#----------------------------------------
# Exchange-Correlation
#----------------------------------------
exchange_correlation = LSDA.PZ

#----------------------------------------
# Numerical Accuracy Settings
#----------------------------------------
left_electrode_numerical_accuracy_parameters = NumericalAccuracyParameters(
    k_point_sampling=(1, 1, 100),
    )

right_electrode_numerical_accuracy_parameters = NumericalAccuracyParameters(
    k_point_sampling=(1, 1, 100),
    )

#----------------------------------------
# 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]]
    )

#----------------------------------------
# Electrode Calculators
#----------------------------------------
left_electrode_calculator = LCAOCalculator(
    exchange_correlation=exchange_correlation,
    numerical_accuracy_parameters=left_electrode_numerical_accuracy_parameters,
    poisson_solver=left_electrode_poisson_solver,
    )

right_electrode_calculator = LCAOCalculator(
    exchange_correlation=exchange_correlation,
    numerical_accuracy_parameters=right_electrode_numerical_accuracy_parameters,
    poisson_solver=right_electrode_poisson_solver,
    )

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

# -------------------------------------------------------------
# Initial State
# -------------------------------------------------------------
initial_spin = InitialSpin(scaled_spins=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])

for bias in [0., 0.1, 0.2, 0.3]*Volt:
    device_configuration.setCalculator(
        calculator(electrode_voltages=(0.5*bias,-0.5*bias)),
        initial_state=device_configuration
    )

    device_configuration.update()
    nlsave('C:/Users/Alexander/Documents/VNL_tmp/carbon_chain.nc', device_configuration)
    nlprint(device_configuration)

Offline 1ight0ne

  • Regular QuantumATK user
  • **
  • Posts: 23
  • Country: ru
  • Reputation: 0
    • View Profile
 Anders Blom, thanks a lot for your answer!

Offline 1ight0ne

  • Regular QuantumATK user
  • **
  • Posts: 23
  • Country: ru
  • Reputation: 0
    • View Profile
Hello! I have a problem with i-v calculation again! I calculating with initial state and use cycle for bias voltage then appears warning: 
The provided initial state parameter has no pre-calculated data. Proceeding without setting an initial state.

Does it means that calculation not include the spin?

Offline 1ight0ne

  • Regular QuantumATK user
  • **
  • Posts: 23
  • Country: ru
  • Reputation: 0
    • View Profile
Somene Help! This is my code:
Code
# -------------------------------------------------------------
# TwoProbe configuration
# -------------------------------------------------------------

# -------------------------------------------------------------
# Left electrode
# -------------------------------------------------------------

# Set up lattice
vector_a = [2.866, 0.0, 0.0]*Angstrom
vector_b = [0.0, 2.866, 0.0]*Angstrom
vector_c = [0.0, 0.0, 5.73200039971]*Angstrom
left_electrode_lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
left_electrode_elements = [Cobalt, Iron, Cobalt, Iron]

# Define coordinates
left_electrode_coordinates = [[ 0.7165    ,  0.7165    ,  0.71650033],
                              [ 2.1495    ,  2.1495    ,  2.14950024],
                              [ 0.7165    ,  0.7165    ,  3.58250053],
                              [ 2.1495    ,  2.1495    ,  5.01550044]]*Angstrom

# Set up configuration
left_electrode = BulkConfiguration(
    bravais_lattice=left_electrode_lattice,
    elements=left_electrode_elements,
    cartesian_coordinates=left_electrode_coordinates
    )

# -------------------------------------------------------------
# Right electrode
# -------------------------------------------------------------

# Set up lattice
vector_a = [2.866, 0.0, 0.0]*Angstrom
vector_b = [0.0, 2.866, 0.0]*Angstrom
vector_c = [0.0, 0.0, 5.73200039972]*Angstrom
right_electrode_lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
right_electrode_elements = [Iron, Cobalt, Iron, Cobalt]

# Define coordinates
right_electrode_coordinates = [[ 0.7165    ,  0.7165    ,  0.71649996],
                               [ 2.1495    ,  2.1495    ,  2.14949987],
                               [ 0.7165    ,  0.7165    ,  3.58250016],
                               [ 2.1495    ,  2.1495    ,  5.01550007]]*Angstrom

# Set up configuration
right_electrode = BulkConfiguration(
    bravais_lattice=right_electrode_lattice,
    elements=right_electrode_elements,
    cartesian_coordinates=right_electrode_coordinates
    )

# -------------------------------------------------------------
# Central region
# -------------------------------------------------------------

# Set up lattice
vector_a = [2.866, 0.0, 0.0]*Angstrom
vector_b = [0.0, 2.866, 0.0]*Angstrom
vector_c = [0.0, 0.0, 36.8717507374]*Angstrom
central_region_lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
central_region_elements = [Cobalt, Iron, Cobalt, Iron, Cobalt, Iron, Cobalt, Iron,
                           Magnesium, Oxygen, Oxygen, Magnesium, Magnesium, Oxygen, Oxygen,
                           Magnesium, Magnesium, Oxygen, Oxygen, Magnesium, Iron, Cobalt,
                           Iron, Cobalt, Iron, Cobalt, Iron, Cobalt]

# Define coordinates
central_region_coordinates = [[  0.7165    ,   0.7165    ,   0.71650033],
                              [  2.1495    ,   2.1495    ,   2.14950024],
                              [  0.7165    ,   0.7165    ,   3.58250053],
                              [  2.1495    ,   2.1495    ,   5.01550044],
                              [  0.7165    ,   0.7165    ,   6.44850036],
                              [  2.1495    ,   2.1495    ,   7.88150027],
                              [  0.7165    ,   0.7165    ,   9.36442933],
                              [  2.1495    ,   2.1495    ,  10.79813571],
                              [  0.7165    ,   0.7165    ,  12.91444474],
                              [  2.1495    ,   2.1495    ,  12.99944039],
                              [  0.7165    ,   0.7165    ,  15.14106372],
                              [  2.1495    ,   2.1495    ,  15.15083326],
                              [  0.7165    ,   0.7165    ,  17.3384058 ],
                              [  2.1495    ,   2.1495    ,  17.33910931],
                              [  0.7165    ,   0.7165    ,  19.53262631],
                              [  2.1495    ,   2.1495    ,  19.53335305],
                              [  0.7165    ,   0.7165    ,  21.72092411],
                              [  2.1495    ,   2.1495    ,  21.73066969],
                              [  0.7165    ,   0.7165    ,  23.87230076],
                              [  2.1495    ,   2.1495    ,  23.95731706],
                              [  0.7165    ,   0.7165    ,  26.0736154 ],
                              [  2.1495    ,   2.1495    ,  27.50733542],
                              [  0.7165    ,   0.7165    ,  28.99025046],
                              [  2.1495    ,   2.1495    ,  30.42325038],
                              [  0.7165    ,   0.7165    ,  31.8562503 ],
                              [  2.1495    ,   2.1495    ,  33.28925021],
                              [  0.7165    ,   0.7165    ,  34.7222505 ],
                              [  2.1495    ,   2.1495    ,  36.15525041]]*Angstrom

# Set up configuration
central_region = BulkConfiguration(
    bravais_lattice=central_region_lattice,
    elements=central_region_elements,
    cartesian_coordinates=central_region_coordinates
    )

device_configuration = DeviceConfiguration(
    central_region,
    [left_electrode, right_electrode]
    )

# -------------------------------------------------------------
# Calculator
# -------------------------------------------------------------
#----------------------------------------
# Basis Set
#----------------------------------------
basis_set = [
    GGABasis.Oxygen_DoubleZetaPolarized,
    GGABasis.Magnesium_DoubleZetaPolarized,
    GGABasis.Iron_SingleZetaPolarized,
    GGABasis.Cobalt_SingleZetaPolarized,
    ]

#----------------------------------------
# Exchange-Correlation
#----------------------------------------
exchange_correlation = SGGA.PBE

#----------------------------------------
# Numerical Accuracy Settings
#----------------------------------------
left_electrode_numerical_accuracy_parameters = NumericalAccuracyParameters(
    k_point_sampling=(6, 6, 100),
    )

right_electrode_numerical_accuracy_parameters = NumericalAccuracyParameters(
    k_point_sampling=(6, 6, 100),
    )

device_numerical_accuracy_parameters = NumericalAccuracyParameters(
    k_point_sampling=(6, 6, 100),
    )

#----------------------------------------
# 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]]
    )

device_algorithm_parameters = DeviceAlgorithmParameters(
    self_energy_calculator_real=KrylovSelfEnergy(save_self_energies=True, lambda_min=0.1),
    )

#----------------------------------------
# Electrode Calculators
#----------------------------------------
left_electrode_calculator = LCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    numerical_accuracy_parameters=left_electrode_numerical_accuracy_parameters,
    poisson_solver=left_electrode_poisson_solver,
    )

right_electrode_calculator = LCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    numerical_accuracy_parameters=right_electrode_numerical_accuracy_parameters,
    poisson_solver=right_electrode_poisson_solver,
    )

#----------------------------------------
# Device Calculator
#----------------------------------------
calculator = DeviceLCAOCalculator(
    basis_set=basis_set,
    exchange_correlation=exchange_correlation,
    numerical_accuracy_parameters=device_numerical_accuracy_parameters,
    device_algorithm_parameters=device_algorithm_parameters,
    electrode_calculators=
        [left_electrode_calculator, right_electrode_calculator],
    )


# -------------------------------------------------------------
# Initial State
# -------------------------------------------------------------
initial_spin = InitialSpin(scaled_spins=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0])

for bias in [0., 0.1, 0.2, 0.3, 0.5]*Volt:  
    device_configuration.setCalculator(  
        calculator(electrode_voltages=(0.5*bias,-0.5*bias)),  
        initial_state=device_configuration
    )  
    
    device_configuration.update()
    nlsave('C:/Users/Alexander/Documents/VNL_tmp/CoFe-MgO-CoFe_anti_I-V.nc', device_configuration)
    nlprint(device_configuration)
I calculate this structure with anti parallel spin and when calculation begin it say: The provided initial state parameter has no pre-calculated data. Proceeding without setting an initial state. Does it means that my calculation not include the spin orientation? When i calculate with parallel spin I see the same message and the same result in I-V curve with Parallel and AntiParallel state. Help me with it and tell what i do wrong!

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Ok, you have to separate two thing. It's normal to get this warning for the first step, since there of course is no initial state there. But it's not related to the spin. HOWEVER, your initial spin is NOT set - you define the variable, but it's never set on the calculator. So it should be
Code: python
for bias in [0., 0.1, 0.2, 0.3, 0.5]*Volt:  
    device_configuration.setCalculator(  
        calculator(electrode_voltages=(0.5*bias,-0.5*bias)),  
        initial_spin=initial_spin,
        initial_state=device_configuration
    )  
« Last Edit: April 11, 2013, 16:47 by Anders Blom »

Offline 1ight0ne

  • Regular QuantumATK user
  • **
  • Posts: 23
  • Country: ru
  • Reputation: 0
    • View Profile
Ok, you have to separate two thing. It's normal to get this warning for the first step, since there of course is no initial state there. But it's not related to the spin. HOWEVER, your initial spin is NOT set - you define the variable, but it's never set on the calculator. So it should be
Code: python
for bias in [0., 0.1, 0.2, 0.3, 0.5]*Volt:  
    device_configuration.setCalculator(  
        calculator(electrode_voltages=(0.5*bias,-0.5*bias)),  
        initial_spin=initial_spin,
        initial_state=device_configuration
    )  
I change this part of code, but its error when start!
Code
Traceback (most recent call last):
  File "c:\temp\3660503366264626.py", line 208, in <module>
    initial_state=device_configuration
  File ".\zipdir\NL\CommonConcepts\Configurations\DeviceConfiguration.py", line 345, in setCalculator
  File ".\zipdir\NL\CommonConcepts\Configurations\AtomicConfiguration.py", line 1076, in setAndCheckInitialSpin
AttributeError: 'NoneType' object has no attribute '_densityMatrixCalculator'

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Sorry for not checking the code. Actually, the way I normally prefer to do this, is to first compute the zero-bias state, and then run the voltage loop based on that. Another important point is that converging the anti-parallel calculation can be hard, and it's then better to use the parallel converged state (zero bias) to initiate the zero-bias anti-parallel calculation. All this is described in the FeMgO tutorial. But to fix your case quickly, use
Code: python
# -------------------------------------------------------------
# Initial State
# -------------------------------------------------------------
initial_spin = InitialSpin(scaled_spins=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0])

device_configuration.setCalculator(calculator, initial_spin=initial_spin)

for bias in [0., 0.1, 0.2, 0.3, 0.5]*Volt:  
    device_configuration.setCalculator(  
        calculator(electrode_voltages=(0.5*bias,-0.5*bias)),  
        initial_state=device_configuration
    )  

Offline 1ight0ne

  • Regular QuantumATK user
  • **
  • Posts: 23
  • Country: ru
  • Reputation: 0
    • View Profile
Sorry for not checking the code. Actually, the way I normally prefer to do this, is to first compute the zero-bias state, and then run the voltage loop based on that. Another important point is that converging the anti-parallel calculation can be hard, and it's then better to use the parallel converged state (zero bias) to initiate the zero-bias anti-parallel calculation. All this is described in the FeMgO tutorial. But to fix your case quickly, use
Code: python
# -------------------------------------------------------------
# Initial State
# -------------------------------------------------------------
initial_spin = InitialSpin(scaled_spins=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0])

device_configuration.setCalculator(calculator, initial_spin=initial_spin)

for bias in [0., 0.1, 0.2, 0.3, 0.5]*Volt:  
    device_configuration.setCalculator(  
        calculator(electrode_voltages=(0.5*bias,-0.5*bias)),  
        initial_state=device_configuration
    )  
Thanks for answer! You said about compute the zero-bias state firstly. You mean i need to compute state with parallel spin and zero bias, then start new calculation for parallel and antiparallel state with bias loop and with mark "old calculation" ?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Right, you would first do the parallel at zero bias, then the voltage loop, starting from the zero case. Then you start the anti-parallel zero bias from the parallel zero bias, and finally the voltage loop for anti-parallel starting from the zero-bias anti-parallel.

Offline 1ight0ne

  • Regular QuantumATK user
  • **
  • Posts: 23
  • Country: ru
  • Reputation: 0
    • View Profile
Right, you would first do the parallel at zero bias, then the voltage loop, starting from the zero case. Then you start the anti-parallel zero bias from the parallel zero bias, and finally the voltage loop for anti-parallel starting from the zero-bias anti-parallel.
I use mark "old calculation" and my script look like this
Code: python
# -------------------------------------------------------------
# Initial State
# -------------------------------------------------------------
initial_spin = InitialSpin(scaled_spins=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
old_calculation = nlread('C:/Users/Alexander/Documents/VNL_tmp/CoFe-MgO-CoFe_para.nc', DeviceConfiguration)[0]

device_configuration.setCalculator(calculator, initial_spin=initial_spin, initial_state=old_calculation)

for bias in [0., 0.1, 0.3, 0.5, 0.7, 1.0, 1.3, 1.5]*Volt:  
    device_configuration.setCalculator(  
        calculator(electrode_voltages=(0.5*bias,-0.5*bias)),  
        initial_state=device_configuration
    )  
    
    device_configuration.update()
    nlsave('C:/Users/Alexander/Documents/VNL_tmp/CoFe-MgO-CoFe_para_I-V.nc', device_configuration)
    nlprint(device_configuration)
but it again shows me that " The provided initial state parameter has no pre-calculated data ..." and it calculates exceed 10 hours/