Author Topic: Are there any questions in this py files?  (Read 3148 times)

0 Members and 1 Guest are viewing this topic.

Offline qiuweicheng

  • Heavy QuantumATK user
  • ***
  • Posts: 38
  • Country: cn
  • Reputation: 0
    • View Profile
Are there any questions in this py files?
« on: July 6, 2017, 02:55 »
I get two py files:
The first: the set calculator is the same with that of BN-AP-0.3.nc
device_configuration = nlread('BN-AP-0.3.nc', DeviceConfiguration)[0]
calculator = device_configuration.calculator()
bias = 0.5*Volt
# -------------------------------------------------------------
# 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, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 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, 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.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, 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.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, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0])
calculator=calculator(
     electrode_voltages=(bias/2, -bias/2))
device_configuration.setCalculator(
     calculator(),
     initial_spin=initial_spin,
     initial_state=device_configuration
     )
device_configuration.update()
nlsave('BN-AP-%.1f.nc' % bias.inUnitsOf(Volt), device_configuration)
# Calculate the transmission
t = TransmissionSpectrum(
    configuration= device_configuration,
    energies = numpy.linspace(-2,2,201)*eV,
    kpoints=MonkhorstPackGrid(30,30),
    energy_zero_parameter=AverageFermiLevel,
    infinitesimal=1e-06*eV,
    self_energy_calculator=RecursionSelfEnergy(),
     ) 
nlsave('BN-AP-%.1f.nc' % bias.inUnitsOf(Volt), t)
nlprint(t)
nlprint("%8.6e %8.6e %8.6e" %(t.bias(), t.current(), t.bias()/t.current())+'\n'),
 
The second: I put BN-AP-0.3.nc into the scripter, and change the initial set.
......
......
#----------------------------------------
# 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,
    numerical_accuracy_parameters=device_numerical_accuracy_parameters,
    electrode_calculators=
        [left_electrode_calculator, right_electrode_calculator],
    electrode_voltages=( 0.2*Volt, -0.2*Volt)
    )

device_configuration.setCalculator(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, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 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, 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.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, 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.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, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0])
old_calculation = nlread('BN-AP-0.3.nc', DeviceConfiguration)[0]
device_configuration.setCalculator(
    calculator,
    initial_spin=initial_spin,
    initial_state=old_calculation,
)
device_configuration.update()
nlsave('BN-AP-0.4.nc', device_configuration)
nlprint(device_configuration)

My question:
1. The set calculator is the same with that of BN-AP-0.3.nc. Are there any difference between two py files?
2. Are there any command problem with the first py file?

Offline Ulrik G. Vej-Hansen

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 425
  • Country: dk
  • Reputation: 8
    • View Profile
Re: Are there any questions in this py files?
« Reply #1 on: July 7, 2017, 13:51 »
I am afraid that I do not understand your question. What are you trying to do, and what is the problem in doing it?

Offline qiuweicheng

  • Heavy QuantumATK user
  • ***
  • Posts: 38
  • Country: cn
  • Reputation: 0
    • View Profile
Re: Are there any questions in this py files?
« Reply #2 on: July 7, 2017, 14:49 »
We can do the calculation using the  existing result (BN-AP-0.3.nc).
But, There are two ways to use existing results.
The question is:
The first way is right?

Offline Petr Khomyakov

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 1290
  • Country: dk
  • Reputation: 25
    • View Profile
Re: Are there any questions in this py files?
« Reply #3 on: July 8, 2017, 23:31 »
You may use the Initial State in the VNL to start the calculation from a converged solution (old calculation), see http://docs.quantumwise.com/tutorials/initialize_from_a_converged_state/initialize_from_a_converged_state.html.

Offline qiuweicheng

  • Heavy QuantumATK user
  • ***
  • Posts: 38
  • Country: cn
  • Reputation: 0
    • View Profile
Re: Are there any questions in this py files?
« Reply #4 on: July 9, 2017, 03:10 »
Yes, I know this tutorials by using  use the Initial State in the VNL to start the calculation from a converged solution (old calculation).  that's completely consistent with the second py file.
and the first py file also uses  use the Initial State in the VNL to start the calculation from a converged solution.
But, in the calculation, the calculation is  convergence by using the first py file.
however, the  calculation is  not convergence by using the second py file.
So, I want to verify that the first py file  are correct?
Why the situation of convergence is different?



Offline Petr Khomyakov

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 1290
  • Country: dk
  • Reputation: 25
    • View Profile
Re: Are there any questions in this py files?
« Reply #5 on: July 10, 2017, 09:00 »
It is not clear what are the calculator settings in the first script. Also, the bias voltage values specified in the two scripts are different.

Offline qiuweicheng

  • Heavy QuantumATK user
  • ***
  • Posts: 38
  • Country: cn
  • Reputation: 0
    • View Profile
Re: Are there any questions in this py files?
« Reply #6 on: July 10, 2017, 09:25 »
In the first py file, we set the calculator = device_configuration.calculator() by using the calculator of ('BN-AP-0.3.nc', DeviceConfiguration)
The calculator is set the same with that of  ('BN-AP-0.3.nc', DeviceConfiguration).
Is this  py command  "calculator = device_configuration.calculator() " set right?
by the way , the calculator set in the second py file is also copyed from the BN-AP-0.3.py.
Except from the bias, are there any difference in the device calculation set between two py files?

Offline Daniele Stradi

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 286
  • Country: dk
  • Reputation: 3
    • View Profile
Re: Are there any questions in this py files?
« Reply #7 on: July 13, 2017, 16:33 »
I do not think it is necessary to set again the initial spin, unless you want to change both the initial spin and the voltage at the same time (which is something I strongly discourage).

If your target is to restart a calculation from a previously converged DeviceConfiguration and change the bias voltage, the script can be as simple as:

bias = 0.5*Volt
device_configuration = nlread('BN-AP-0.3.nc', DeviceConfiguration)[-1]
calculator = device_configuration.calculator()
calculator=calculator(electrode_voltages=(bias/2, -bias/2))
device_configuration.setCalculator(
      calculator(),
      initial_state=device_configuration)
device_configuration.update()
nlsave('output.nc', device_configuration)

Offline qiuweicheng

  • Heavy QuantumATK user
  • ***
  • Posts: 38
  • Country: cn
  • Reputation: 0
    • View Profile
Re: Are there any questions in this py files?
« Reply #8 on: July 19, 2017, 14:26 »
Thank you for your reply. But, you set the device_configuration = nlread('BN-AP-0.3.nc', DeviceConfiguration)[-1]? I think it  should be device_configuration = nlread('BN-AP-0.3.nc', DeviceConfiguration)[0]
Or what is the difference between ('BN-AP-0.3.nc', DeviceConfiguration)[-1] and ('BN-AP-0.3.nc', DeviceConfiguration)[0]?

Offline Daniele Stradi

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 286
  • Country: dk
  • Reputation: 3
    • View Profile
Re: Are there any questions in this py files?
« Reply #9 on: July 19, 2017, 14:58 »
It is just that in Python one can choose to read a list from the beginning, or from the end  :)

('BN-AP-0.3.nc', DeviceConfiguration)[0] : if you have N DeviceConfiguration objects, it takes the first one (with index = 0)
('BN-AP-0.3.nc', DeviceConfiguration)[-1] : if you have N DeviceConfiguration objects, it takes the last one (with index = N-1)