QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: BandTheory on February 18, 2010, 20:44

Title: Trouble Restarting from a checkpoint file
Post by: BandTheory on February 18, 2010, 20:44
I am trying to restart an aborted calculation using a checkpoint file. It is my understanding that executeSelfConsistentCalculation() will take a restoreSelfConsistentCalculation object as an argument.  I tried this and got the following error:

Traceback (most recent call last):
  File "<string>", line 11, in ?
KeyError: 'Electrode'


My code basically looks like this.

from ATK.KohnSham import *
from ATK.MPI import*

sc_calc = restoreSelfConsistentCalculation('/filepath/filename.nc')

scf = executeSelfConsistentCalculation(
self_consitent_calculation = sc_calc
)


if processIsMaster():
        print calculateTotalEnergy(scf)

I'd like to salvage this calculation if possible and I would really appreciate the help.
Thanks,

BT


Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on February 18, 2010, 22:09
You import the KohnSham module, but the restored SCF is a two-probe. So, try

Code
from ATK.TwoProbe import *

instead, and I think it will work.

Title: Re: Trouble Restarting from a checkpoint file
Post by: BandTheory on February 21, 2010, 04:23
I made the switch, but I receive the same error.  I also tried importing KhonSham and TwoProbe, but received the same output.
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on February 21, 2010, 19:18
Do you know if the original calculation was interrupted in the two-probe part or the equivalent electrode part?

Unfortunately the (old) NetCDF files are not very transparent, so unless the standard approach works, there's probably not much that can be done manually either.

There is a tool called ncview (ftp://cirrus.ucsd.edu/pub/ncview/) that you perhaps can use to inspect the contents of the NC file, but again, it seems unlikely this will resolve it. But post it, if you get it to work, and we can have a look and help you interpret it.

There is a separate approach to using the NetCDF file, which is not a restart but rather an initialization. If you restore the SCF object in the same way, but use
Code
initial_calculation = sc_calc


instead, you can use the fact that you were already on your way to convergence to save time. Again, this requires the NC file to be in an appropriate state, so there is no guarantee this will work either, given the situation with the restart. Also note that in this case you have to define the entire calculation again, so what you do is go back to the original script and just insert two lines, one to restore the NC file, and one which adds the statement above to the executeSelfConsistentCalculation() call.

Good luck!
Title: Re: Trouble Restarting from a checkpoint file
Post by: BandTheory on February 22, 2010, 18:17
Well I am using Neutral Atom density because I have heterogeneous electrodes.  I don't know if that makes any difference.

I think I will first try running my initial script with 'initial_calculation = sc_calc" and if that does not work I will just restart the whole thing from scratch.

Thanks for the help.
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on August 18, 2010, 15:09
Dear all,

I had a power failure and have wrongly modified the script as shown below.

I restored from 'crash.nc' and if you see the last few lines of the code after # Initialize self-consistent field calculation i defined checkpoint as 'crash_1.nc'.

Now the program has created crash_1.nc and is modifying it regularly. Also, crash.nc is accesed frequently.

The script below is only a sample, the program is still running and is doing two probe calculation. I do not know what is happening and request you to suggest a solution to save my time. If possible please suggest modifications to this script.

Code: python
from ATK.TwoProbe import *
old_scf = restoreSelfConsistentCalculation('crash.nc')
scf = executeSelfConsistentCalculation(self_consistent_calculation=old_scf)
from ATK.MPI import processIsMaster
import ivcurve

# Generate time stamp
if processIsMaster():
    import platform, time
    print '#',time.ctime()
    print '#',platform.node(),platform.platform()+'\n'

# Opening vnlfile
if processIsMaster(): file = VNLFile('twoprobe.vnl')

# Scattering elements
left_surface_elements  = [Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon]
central_atom_elements  = [Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon]
right_surface_elements = [Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon,
                          Carbon, Carbon, Carbon, Carbon]
scattering_elements = left_surface_elements + central_atom_elements + right_surface_elements

# Scattering coordinates
left_surface_coordinates  = [[ 10.32234097,   7.60652113,   2.46297622],
                             [  7.60652113,  10.32234097,   2.46297622],
                             [  4.89070082,   7.60652113,   2.46297622],
                             [  7.60652113,   4.89070082,   2.46297622],
                             [  9.95849037,   8.96443081,   2.46297622],
                             [  6.24861097,   9.95849037,   2.46297622],
                             [  5.25455189,   6.24861097,   2.46297622],
                             [  8.96443081,   5.25455189,   2.46297622],
                             [  9.52689552,   9.52689552,   3.69446445],
                             [  5.68614626,   9.52689552,   3.69446445],
                             [  5.68614626,   5.68614626,   3.69446445],
                             [  9.52689552,   5.68614626,   3.69446445],
                             [  8.30942726,  10.22980118,   3.69446445],
                             [  4.98324013,   8.30942726,   3.69446445],
                             [  6.903615  ,   4.98324013,   3.69446445],
                             [ 10.22980118,   6.903615  ,   3.69446445]]*Angstrom
central_atom_coordinates  = [[ 10.32234097,   7.60652113,   4.92602378],
                             [  9.52689552,   9.52689552,   6.15751189],
                             [  7.60652113,  10.32234097,   4.92602378],
                             [  5.68614626,   9.52689552,   6.15751189],
                             [  4.89070082,   7.60652113,   4.92602378],
                             [  5.68614626,   5.68614626,   6.15751189],
                             [  7.60652113,   4.89070082,   4.92602378],
                             [  9.52689552,   5.68614626,   6.15751189],
                             [  9.95849037,   8.96443081,   4.92602378],
                             [  8.30942726,  10.22980118,   6.15751189],
                             [  6.24861097,   9.95849037,   4.92602378],
                             [  4.98324013,   8.30942726,   6.15751189],
                             [  5.25455189,   6.24861097,   4.92602378],
                             [  6.903615  ,   4.98324013,   6.15751189],
                             [  8.96443081,   5.25455189,   4.92602378],
                             [ 10.22980118,   6.903615  ,   6.15751189],
                             [ 10.32234097,   7.60652113,   7.389     ],
                             [  9.52689552,   9.52689552,   8.62048811],
                             [  7.60652113,  10.32234097,   7.389     ],
                             [  5.68614626,   9.52689552,   8.62048811],
                             [  4.89070082,   7.60652113,   7.389     ],
                             [  5.68614626,   5.68614626,   8.62048811],
                             [  7.60652113,   4.89070082,   7.389     ],
                             [  9.52689552,   5.68614626,   8.62048811],
                             [  9.95849037,   8.96443081,   7.389     ],
                             [  8.30942726,  10.22980118,   8.62048811],
                             [  6.24861097,   9.95849037,   7.389     ],
                             [  4.98324013,   8.30942726,   8.62048811],
                             [  5.25455189,   6.24861097,   7.389     ],
                             [  6.903615  ,   4.98324013,   8.62048811],
                             [  8.96443081,   5.25455189,   7.389     ],
                             [ 10.22980118,   6.903615  ,   8.62048811]]*Angstrom
right_surface_coordinates = [[ 10.32234097,   7.60652113,   9.85146421],
                             [  7.60652113,  10.32234097,   9.85146421],
                             [  4.89070082,   7.60652113,   9.85146421],
                             [  7.60652113,   4.89070082,   9.85146421],
                             [  9.95849037,   8.96443081,   9.85146421],
                             [  6.24861097,   9.95849037,   9.85146421],
                             [  5.25455189,   6.24861097,   9.85146421],
                             [  8.96443081,   5.25455189,   9.85146421],
                             [  9.52689552,   9.52689552,  11.08295232],
                             [  5.68614626,   9.52689552,  11.08295232],
                             [  5.68614626,   5.68614626,  11.08295232],
                             [  9.52689552,   5.68614626,  11.08295232],
                             [  8.30942726,  10.22980118,  11.08295232],
                             [  4.98324013,   8.30942726,  11.08295232],
                             [  6.903615  ,   4.98324013,  11.08295232],
                             [ 10.22980118,   6.903615  ,  11.08295232]]*Angstrom
scattering_coordinates = left_surface_coordinates + central_atom_coordinates + right_surface_coordinates

electrode_elements = [Carbon, Carbon, Carbon, Carbon,
                      Carbon, Carbon, Carbon, Carbon,
                      Carbon, Carbon, Carbon, Carbon,
                      Carbon, Carbon, Carbon, Carbon]
electrode_coordinates = [[ 10.32234097,   7.60652113,   0.        ],
                         [  9.52689552,   9.52689552,   1.23148811],
                         [  7.60652113,  10.32234097,   0.        ],
                         [  5.68614626,   9.52689552,   1.23148811],
                         [  4.89070082,   7.60652113,   0.        ],
                         [  5.68614626,   5.68614626,   1.23148811],
                         [  7.60652113,   4.89070082,   0.        ],
                         [  9.52689552,   5.68614626,   1.23148811],
                         [  9.95849037,   8.96443081,   0.        ],
                         [  8.30942726,  10.22980118,   1.23148811],
                         [  6.24861097,   9.95849037,   0.        ],
                         [  4.98324013,   8.30942726,   1.23148811],
                         [  5.25455189,   6.24861097,   0.        ],
                         [  6.903615  ,   4.98324013,   1.23148811],
                         [  8.96443081,   5.25455189,   0.        ],
                         [ 10.22980118,   6.903615  ,   1.23148811]]*Angstrom

electrode_cell = [[ 15.2130418 ,   0.        ,   0.        ],
                  [  0.        ,  15.2130418 ,   0.        ],
                  [  0.        ,   0.        ,   2.46297625]]*Angstrom

# Set up electrodes
electrode_configuration = PeriodicAtomConfiguration(
    electrode_cell,
    electrode_elements,
    electrode_coordinates
    )

# Set up two-probe configuration
twoprobe_configuration = TwoProbeConfiguration(
    (electrode_configuration,electrode_configuration),
    scattering_elements,
    scattering_coordinates,
    electrode_repetitions=[[1,1],[1,1]],
    equivalent_atoms=([0,0],[1,56])
    )
if processIsMaster(): nlPrint(twoprobe_configuration)
if processIsMaster(): file.addToSample(twoprobe_configuration, 'twoprobe_configuration')

######################################################################
# Central region parameters
######################################################################
exchange_correlation_type = LDA.PZ

iteration_mixing_parameters = iterationMixingParameters(
    algorithm = IterationMixing.Pulay,
    diagonal_mixing_parameter = 0.1,
    quantity = IterationMixing.Hamiltonian,
    history_steps = 6
)

electron_density_parameters = electronDensityParameters(
    mesh_cutoff = 400.0*Rydberg
)

basis_set_parameters = basisSetParameters(
    type = DoubleZetaPolarized,
    radial_sampling_dr = 0.001*Bohr,
    energy_shift = 0.01*Rydberg,
    delta_rinn = 0.8,
    v0 = 40.0*Rydberg,
    charge = 0.0,
    split_norm = 0.15
)

iteration_control_parameters = iterationControlParameters(
    tolerance = 1e-005,
    criterion = IterationControl.TotalEnergy,
    max_steps = 100
)

electrode_voltages = (0.0,0.0)*Volt

two_probe_algorithm_parameters = twoProbeAlgorithmParameters(
    electrode_constraint = ElectrodeConstraints.Off,
    initial_density_type = InitialDensityType.EquivalentBulk
)

energy_contour_integral_parameters = energyContourIntegralParameters(
    circle_points = 30,
    integral_lower_bound = 3.0*Rydberg,
    fermi_line_points = 10,
    fermi_function_poles = 4,
    real_axis_infinitesimal = 0.01*electronVolt,
    real_axis_point_density = 0.02*electronVolt
)

two_center_integral_parameters = twoCenterIntegralParameters(
    cutoff = 2500.0*Rydberg,
    points = 1024
)

######################################################################
# Left electrode parameters
######################################################################
left_electrode_electron_density_parameters = electronDensityParameters(
    mesh_cutoff = 400.0*Rydberg
)

left_electrode_iteration_control_parameters = iterationControlParameters(
    tolerance = 1e-005,
    criterion = IterationControl.TotalEnergy,
    max_steps = 100
)

left_electrode_brillouin_zone_integration_parameters = brillouinZoneIntegrationParameters(
    monkhorst_pack_parameters = (1, 1, 500)
)

left_electrode_iteration_mixing_parameters = iterationMixingParameters(
    algorithm = IterationMixing.Pulay,
    diagonal_mixing_parameter = 0.1,
    quantity = IterationMixing.Hamiltonian,
    history_steps = 6
)

left_electrode_eigenstate_occupation_parameters = eigenstateOccupationParameters(
    temperature = 300.0*Kelvin
)

######################################################################
# Collect left electrode parameters
######################################################################
left_electrode_parameters = ElectrodeParameters(
    brillouin_zone_integration_parameters = left_electrode_brillouin_zone_integration_parameters,
    electron_density_parameters = left_electrode_electron_density_parameters,
    eigenstate_occupation_parameters = left_electrode_eigenstate_occupation_parameters,
    iteration_mixing_parameters = left_electrode_iteration_mixing_parameters,
    iteration_control_parameters = left_electrode_iteration_control_parameters
)

######################################################################
# Right electrode parameters
######################################################################
right_electrode_electron_density_parameters = electronDensityParameters(
    mesh_cutoff = 400.0*Rydberg
)

right_electrode_iteration_control_parameters = iterationControlParameters(
    tolerance = 1e-005,
    criterion = IterationControl.TotalEnergy,
    max_steps = 100
)

right_electrode_brillouin_zone_integration_parameters = brillouinZoneIntegrationParameters(
    monkhorst_pack_parameters = (1, 1, 500)
)

right_electrode_iteration_mixing_parameters = iterationMixingParameters(
    algorithm = IterationMixing.Pulay,
    diagonal_mixing_parameter = 0.1,
    quantity = IterationMixing.Hamiltonian,
    history_steps = 6
)

right_electrode_eigenstate_occupation_parameters = eigenstateOccupationParameters(
    temperature = 300.0*Kelvin
)

######################################################################
# Collect right electrode parameters
######################################################################
right_electrode_parameters = ElectrodeParameters(
    brillouin_zone_integration_parameters = right_electrode_brillouin_zone_integration_parameters,
    electron_density_parameters = right_electrode_electron_density_parameters,
    eigenstate_occupation_parameters = right_electrode_eigenstate_occupation_parameters,
    iteration_mixing_parameters = right_electrode_iteration_mixing_parameters,
    iteration_control_parameters = right_electrode_iteration_control_parameters
)

######################################################################
# Initialize self-consistent field calculation
######################################################################
two_probe_method = TwoProbeMethod(
    electrode_parameters = (left_electrode_parameters,right_electrode_parameters),
    exchange_correlation_type = exchange_correlation_type,
    iteration_mixing_parameters = iteration_mixing_parameters,
    electron_density_parameters = electron_density_parameters,
    basis_set_parameters = basis_set_parameters,
    iteration_control_parameters = iteration_control_parameters,
    energy_contour_integral_parameters = energy_contour_integral_parameters,
    two_center_integral_parameters = two_center_integral_parameters,
    electrode_voltages = electrode_voltages,
    algorithm_parameters = two_probe_algorithm_parameters
)
if processIsMaster(): nlPrint(two_probe_method)

runtime_parameters = runtimeParameters(
    verbosity_level = 10,
    checkpoint_filename = 'crash_1.nc'
)

voltages=[0.0,0.5,1.0,1.5]*Volt

ivcurve.runIVcurve (
    twoprobe_configuration,
    two_probe_method,
    runtime_parameters,
    voltages,
    vnl_filename='twoprobe_iv.vnl', sample_name='twoprobe',
    current_k_point_sampling = (10,10),
    current_number_of_points = 100
  )

Moderator edit: use of code tags make it easier to read post
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on August 21, 2010, 16:04
Ok, I modified script to start from checkpoint file. Kindly check.

Code: python
from ATK.TwoProbe import *
from ATK.MPI import processIsMaster
import ivcurve

# Generate time stamp
if processIsMaster():
    import platform, time
    print '#',time.ctime()
    print '#',platform.node(),platform.platform()+'\n'

# Opening vnlfile

if processIsMaster(): file = VNLFile('twoprobe.vnl')
old_scf = restoreSelfConsistentCalculation('crash.nc')
import ATK
ATK.setCheckpointFilename('crash1.nc')
ATK.setVerbosityLevel(10)
scf = executeSelfConsistentCalculation(self_consistent_calculation=old_scf)

voltages=[0.0,0.5,1.0,1.5]*Volt

ivcurve.runIVcurve (
    twoprobe_configuration,
    two_probe_method,
    runtime_parameters,
    voltages,
    vnl_filename='twoprobe_iv.vnl', sample_name='twoprobe',
    current_k_point_sampling = (10,10),
    current_number_of_points = 100
  )

Moderator edit: use of code tags make it easier to read post
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on August 21, 2010, 19:47
I'm not sure what your question is...? The last script will fail because none of the variables you provide to "ivcurve" is defined.

In general, when running an IV sweep like this, you cannot just directly use the crashed calculation to restart, unless you modify the ivcurve.py script yourself. (Note that your variable "scf" is never used after it's defined.)

PS: A general suggestion: place Python code inside "code" tags, makes it much easier to read.
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on August 23, 2010, 08:06
Dear Sir, My question is

-- I am doing a two probe I-V char. estimation for which i made a check-point file. Now, I want to restart from the check-point file.
-- I don't have zero_bias.nc since the program was interrupted during two probe calculation part.
-- I don't know how to modify ivscript.py, which you have suggested.
-- Please see the attached script and if possible make corrections so as to restart from the check-point file.
-- Also, please give an example to start from zero_bias.nc.

best regards...
Title: Re: Trouble Restarting from a checkpoint file
Post by: zh on August 23, 2010, 10:35
Since you don't have the zero_bias.nc, a calculation restarting from the crashed job may not helpful to save time. It is better to do a completely new calculation.

The example for a calculation starting from zero voltage:
http://www.quantumwise.com/documents/manuals/ATK-2008.10/chap.litwoprobe.html#sect2.litwoprobe.running
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on August 23, 2010, 10:43
Thank you Zh (sir).

-- I would also like to know the changes in the script/ivscript.py when I have "zero_bias.nc" and want to simulate on other bias values (bias sweep).

best regards....
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on August 23, 2010, 10:56
I prefer not to post a new script to address this, it will just become too overloaded with options. Instead, let us show how easy it is to customize things in Python.

If you open your ivcurve.py script in an editor and go to lines 46-47, you will find

Code: python
    # No initial calculation for the first voltage
    scf = None

Simply insert here your zero-bias calculation, like for instance


Code: python
    # Initial calculation for the first voltage
    scf = restoreSelfConsistentCalculation("zerobias.nc")

and you're good to go. (Remember to keep the original indentation depth; these lines appear inside a function. I kept the indentation in the above code lines, to make it easier to copy/paste them.)
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on August 23, 2010, 14:54
Ok, I understood how to modify "ivscript.py" for restarting from "zero_bias.nc"

I modified the code as you said, please check whether it is correct or not.

Code
from ATK.TwoProbe import *  
from ATK.MPI import processIsMaster 
import ivcurve 
   
# Generate time stamp 
 if processIsMaster(): 
     import platform, time 
     print '#',time.ctime() 
     print '#',platform.node(),platform.platform()+'\n' 
   
 # Opening vnlfile 
   
 if processIsMaster(): file = VNLFile('twoprobe.vnl') 
 old_scf = restoreSelfConsistentCalculation('zero_bias.nc') 

 # New checkpoint file

 import ATK
 ATK.setCheckpointFilename('crash1.nc') 
 ATK.setVerbosityLevel(10)
 
# initialize self consistent calculation
 
 scf = executeSelfConsistentCalculation(self_consistent_calculation=old_scf) 

# Set up electrodes
electrode_configuration = PeriodicAtomConfiguration(
    electrode_cell,
    electrode_elements,
    electrode_coordinates
    )

# Set up two-probe configuration
twoprobe_configuration = TwoProbeConfiguration(
    (electrode_configuration,electrode_configuration),
    scattering_elements,
    scattering_coordinates,
    electrode_repetitions=[[1,1],[1,1]],
    equivalent_atoms=([0,0],[1,56])
    )
if processIsMaster(): nlPrint(twoprobe_configuration)
if processIsMaster(): file.addToSample(twoprobe_configuration, 'twoprobe_configuration')

######################################################################
# Central region parameters
######################################################################
exchange_correlation_type = LDA.PZ

iteration_mixing_parameters = iterationMixingParameters(
    algorithm = IterationMixing.Pulay,
    diagonal_mixing_parameter = 0.1,
    quantity = IterationMixing.Hamiltonian,
    history_steps = 6
)

electron_density_parameters = electronDensityParameters(
    mesh_cutoff = 400.0*Rydberg
)

basis_set_parameters = basisSetParameters(
    type = DoubleZetaPolarized,
    radial_sampling_dr = 0.001*Bohr,
    energy_shift = 0.01*Rydberg,
    delta_rinn = 0.8,
    v0 = 40.0*Rydberg,
    charge = 0.0,
    split_norm = 0.15
)

iteration_control_parameters = iterationControlParameters(
    tolerance = 1e-005,
    criterion = IterationControl.TotalEnergy,
    max_steps = 100
)

electrode_voltages = (0.0,0.0)*Volt

two_probe_algorithm_parameters = twoProbeAlgorithmParameters(
    electrode_constraint = ElectrodeConstraints.Off,
    initial_density_type = InitialDensityType.EquivalentBulk
)

energy_contour_integral_parameters = energyContourIntegralParameters(
    circle_points = 30,
    integral_lower_bound = 3.0*Rydberg,
    fermi_line_points = 10,
    fermi_function_poles = 4,
    real_axis_infinitesimal = 0.01*electronVolt,
    real_axis_point_density = 0.02*electronVolt
)

two_center_integral_parameters = twoCenterIntegralParameters(
    cutoff = 2500.0*Rydberg,
    points = 1024
)

######################################################################
# Left electrode parameters
######################################################################
left_electrode_electron_density_parameters = electronDensityParameters(
    mesh_cutoff = 400.0*Rydberg
)

left_electrode_iteration_control_parameters = iterationControlParameters(
    tolerance = 1e-005,
    criterion = IterationControl.TotalEnergy,
    max_steps = 100
)

left_electrode_brillouin_zone_integration_parameters = brillouinZoneIntegrationParameters(
    monkhorst_pack_parameters = (1, 1, 500)
)

left_electrode_iteration_mixing_parameters = iterationMixingParameters(
    algorithm = IterationMixing.Pulay,
    diagonal_mixing_parameter = 0.1,
    quantity = IterationMixing.Hamiltonian,
    history_steps = 6
)

left_electrode_eigenstate_occupation_parameters = eigenstateOccupationParameters(
    temperature = 300.0*Kelvin
)

######################################################################
# Collect left electrode parameters
######################################################################
left_electrode_parameters = ElectrodeParameters(
    brillouin_zone_integration_parameters = left_electrode_brillouin_zone_integration_parameters,
    electron_density_parameters = left_electrode_electron_density_parameters,
    eigenstate_occupation_parameters = left_electrode_eigenstate_occupation_parameters,
    iteration_mixing_parameters = left_electrode_iteration_mixing_parameters,
    iteration_control_parameters = left_electrode_iteration_control_parameters
)

######################################################################
# Right electrode parameters
######################################################################
right_electrode_electron_density_parameters = electronDensityParameters(
    mesh_cutoff = 400.0*Rydberg
)

right_electrode_iteration_control_parameters = iterationControlParameters(
    tolerance = 1e-005,
    criterion = IterationControl.TotalEnergy,
    max_steps = 100
)

right_electrode_brillouin_zone_integration_parameters = brillouinZoneIntegrationParameters(
    monkhorst_pack_parameters = (1, 1, 500)
)

right_electrode_iteration_mixing_parameters = iterationMixingParameters(
    algorithm = IterationMixing.Pulay,
    diagonal_mixing_parameter = 0.1,
    quantity = IterationMixing.Hamiltonian,
    history_steps = 6
)

right_electrode_eigenstate_occupation_parameters = eigenstateOccupationParameters(
    temperature = 300.0*Kelvin
)

######################################################################
# Collect right electrode parameters
######################################################################
right_electrode_parameters = ElectrodeParameters(
    brillouin_zone_integration_parameters = right_electrode_brillouin_zone_integration_parameters,
    electron_density_parameters = right_electrode_electron_density_parameters,
    eigenstate_occupation_parameters = right_electrode_eigenstate_occupation_parameters,
    iteration_mixing_parameters = right_electrode_iteration_mixing_parameters,
    iteration_control_parameters = right_electrode_iteration_control_parameters
)

######################################################################
# Initialize self-consistent field calculation
######################################################################
two_probe_method = TwoProbeMethod(
    electrode_parameters = (left_electrode_parameters,right_electrode_parameters),
    exchange_correlation_type = exchange_correlation_type,
    iteration_mixing_parameters = iteration_mixing_parameters,
    electron_density_parameters = electron_density_parameters,
    basis_set_parameters = basis_set_parameters,
    iteration_control_parameters = iteration_control_parameters,
    energy_contour_integral_parameters = energy_contour_integral_parameters,
    two_center_integral_parameters = two_center_integral_parameters,
    electrode_voltages = electrode_voltages,
    algorithm_parameters = two_probe_algorithm_parameters
)
if processIsMaster(): nlPrint(two_probe_method)

voltages=[0.0,0.5,1.0,1.5]*Volt

ivcurve.runIVcurve (
    twoprobe_configuration,
    two_probe_method,
    runtime_parameters,
    voltages,
    vnl_filename='twoprobe_iv.vnl', sample_name='twoprobe',
    current_k_point_sampling = (10,10),
    current_number_of_points = 100
  )
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on August 31, 2010, 16:22
Dear Sir,

the script ivcurve.py should generate separate checkpoint file for each bias voltage.

---I found it true in windows-XP, but even if i provide a path to the check point files, they are unfortunately stored in C:/documents and settings/user folder. I don not know why ?

---In Linux, only one check point file is created in the desired location, instead of one file for each bias. I do not know why?

Please explain....

best,
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on August 31, 2010, 23:21
The question is probably quite easy to answer if one sees all the relevant scripts, but very difficult to answer without them...
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on September 1, 2010, 07:22
I have attached the ivscript.py and the script.
In Linux the script makes only one checkpoint  file.

Code
from ATK.TwoProbe import *

from ATK.MPI import processIsMaster

import ivcurve



# Generate time stamp

if processIsMaster():

    import platform, time

    print '#',time.ctime()

    print '#',platform.node(),platform.platform()+'\n'



# Opening vnlfile

if processIsMaster(): file = VNLFile('/home/hellboy/Desktop/NanoLab simulations/SWCNT 44 Two probe/SWCNT44twoprobe.vnl')



# Scattering elements

left_surface_elements  = [Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon]

central_atom_elements  = [Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon]

right_surface_elements = [Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon,

                          Carbon, Carbon, Carbon, Carbon]

scattering_elements = left_surface_elements + central_atom_elements + right_surface_elements



# Scattering coordinates

left_surface_coordinates  = [[ 10.32234097,   7.60652113,   2.46297622],

                             [  7.60652113,  10.32234097,   2.46297622],

                             [  4.89070082,   7.60652113,   2.46297622],

                             [  7.60652113,   4.89070082,   2.46297622],

                             [  9.95849037,   8.96443081,   2.46297622],

                             [  6.24861097,   9.95849037,   2.46297622],

                             [  5.25455189,   6.24861097,   2.46297622],

                             [  8.96443081,   5.25455189,   2.46297622],

                             [  9.52689552,   9.52689552,   3.69446445],

                             [  5.68614626,   9.52689552,   3.69446445],

                             [  5.68614626,   5.68614626,   3.69446445],

                             [  9.52689552,   5.68614626,   3.69446445],

                             [  8.30942726,  10.22980118,   3.69446445],

                             [  4.98324013,   8.30942726,   3.69446445],

                             [  6.903615  ,   4.98324013,   3.69446445],

                             [ 10.22980118,   6.903615  ,   3.69446445]]*Angstrom

central_atom_coordinates  = [[ 10.32234097,   7.60652113,   4.92602378],

                             [  9.52689552,   9.52689552,   6.15751189],

                             [  7.60652113,  10.32234097,   4.92602378],

                             [  5.68614626,   9.52689552,   6.15751189],

                             [  4.89070082,   7.60652113,   4.92602378],

                             [  5.68614626,   5.68614626,   6.15751189],

                             [  7.60652113,   4.89070082,   4.92602378],

                             [  9.52689552,   5.68614626,   6.15751189],

                             [  9.95849037,   8.96443081,   4.92602378],

                             [  8.30942726,  10.22980118,   6.15751189],

                             [  6.24861097,   9.95849037,   4.92602378],

                             [  4.98324013,   8.30942726,   6.15751189],

                             [  5.25455189,   6.24861097,   4.92602378],

                             [  6.903615  ,   4.98324013,   6.15751189],

                             [  8.96443081,   5.25455189,   4.92602378],

                             [ 10.22980118,   6.903615  ,   6.15751189],

                             [ 10.32234097,   7.60652113,   7.389     ],

                             [  9.52689552,   9.52689552,   8.62048811],

                             [  7.60652113,  10.32234097,   7.389     ],

                             [  5.68614626,   9.52689552,   8.62048811],

                             [  4.89070082,   7.60652113,   7.389     ],

                             [  5.68614626,   5.68614626,   8.62048811],

                             [  7.60652113,   4.89070082,   7.389     ],

                             [  9.52689552,   5.68614626,   8.62048811],

                             [  9.95849037,   8.96443081,   7.389     ],

                             [  8.30942726,  10.22980118,   8.62048811],

                             [  6.24861097,   9.95849037,   7.389     ],

                             [  4.98324013,   8.30942726,   8.62048811],

                             [  5.25455189,   6.24861097,   7.389     ],

                             [  6.903615  ,   4.98324013,   8.62048811],

                             [  8.96443081,   5.25455189,   7.389     ],

                             [ 10.22980118,   6.903615  ,   8.62048811]]*Angstrom

right_surface_coordinates = [[ 10.32234097,   7.60652113,   9.85146421],

                             [  7.60652113,  10.32234097,   9.85146421],

                             [  4.89070082,   7.60652113,   9.85146421],

                             [  7.60652113,   4.89070082,   9.85146421],

                             [  9.95849037,   8.96443081,   9.85146421],

                             [  6.24861097,   9.95849037,   9.85146421],

                             [  5.25455189,   6.24861097,   9.85146421],

                             [  8.96443081,   5.25455189,   9.85146421],

                             [  9.52689552,   9.52689552,  11.08295232],

                             [  5.68614626,   9.52689552,  11.08295232],

                             [  5.68614626,   5.68614626,  11.08295232],

                             [  9.52689552,   5.68614626,  11.08295232],

                             [  8.30942726,  10.22980118,  11.08295232],

                             [  4.98324013,   8.30942726,  11.08295232],

                             [  6.903615  ,   4.98324013,  11.08295232],

                             [ 10.22980118,   6.903615  ,  11.08295232]]*Angstrom

scattering_coordinates = left_surface_coordinates + central_atom_coordinates + right_surface_coordinates



electrode_elements = [Carbon, Carbon, Carbon, Carbon,

                      Carbon, Carbon, Carbon, Carbon,

                      Carbon, Carbon, Carbon, Carbon,

                      Carbon, Carbon, Carbon, Carbon]

electrode_coordinates = [[ 10.32234097,   7.60652113,   0.        ],

                         [  9.52689552,   9.52689552,   1.23148811],

                         [  7.60652113,  10.32234097,   0.        ],

                         [  5.68614626,   9.52689552,   1.23148811],

                         [  4.89070082,   7.60652113,   0.        ],

                         [  5.68614626,   5.68614626,   1.23148811],

                         [  7.60652113,   4.89070082,   0.        ],

                         [  9.52689552,   5.68614626,   1.23148811],

                         [  9.95849037,   8.96443081,   0.        ],

                         [  8.30942726,  10.22980118,   1.23148811],

                         [  6.24861097,   9.95849037,   0.        ],

                         [  4.98324013,   8.30942726,   1.23148811],

                         [  5.25455189,   6.24861097,   0.        ],

                         [  6.903615  ,   4.98324013,   1.23148811],

                         [  8.96443081,   5.25455189,   0.        ],

                         [ 10.22980118,   6.903615  ,   1.23148811]]*Angstrom



electrode_cell = [[ 15.2130418 ,   0.        ,   0.        ],

                  [  0.        ,  15.2130418 ,   0.        ],

                  [  0.        ,   0.        ,   2.46297625]]*Angstrom



# Set up electrodes

electrode_configuration = PeriodicAtomConfiguration(

    electrode_cell,

    electrode_elements,

    electrode_coordinates

    )



# Set up two-probe configuration

twoprobe_configuration = TwoProbeConfiguration(

    (electrode_configuration,electrode_configuration),

    scattering_elements,

    scattering_coordinates,

    electrode_repetitions=[[1,1],[1,1]],

    equivalent_atoms=([0,0],[1,56])

    )

if processIsMaster(): nlPrint(twoprobe_configuration)

if processIsMaster(): file.addToSample(twoprobe_configuration, 'twoprobe_configuration')



######################################################################

# Central region parameters

######################################################################

exchange_correlation_type = LDA.PZ



iteration_mixing_parameters = iterationMixingParameters(

    algorithm = IterationMixing.Pulay,

    diagonal_mixing_parameter = 0.1,

    quantity = IterationMixing.Hamiltonian,

    history_steps = 6

)



electron_density_parameters = electronDensityParameters(

    mesh_cutoff = 400.0*Rydberg

)



basis_set_parameters = basisSetParameters(

    type = DoubleZetaPolarized,

    radial_sampling_dr = 0.001*Bohr,

    energy_shift = 0.01*Rydberg,

    delta_rinn = 0.8,

    v0 = 40.0*Rydberg,

    charge = 0.0,

    split_norm = 0.15

)



iteration_control_parameters = iterationControlParameters(

    tolerance = 1e-005,

    criterion = IterationControl.TotalEnergy,

    max_steps = 100

)



electrode_voltages = (0.0,0.0)*Volt



two_probe_algorithm_parameters = twoProbeAlgorithmParameters(

    electrode_constraint = ElectrodeConstraints.Off,

    initial_density_type = InitialDensityType.EquivalentBulk

)



energy_contour_integral_parameters = energyContourIntegralParameters(

    circle_points = 30,

    integral_lower_bound = 3.0*Rydberg,

    fermi_line_points = 10,

    fermi_function_poles = 4,

    real_axis_infinitesimal = 0.01*electronVolt,

    real_axis_point_density = 0.02*electronVolt

)



two_center_integral_parameters = twoCenterIntegralParameters(

    cutoff = 2500.0*Rydberg,

    points = 1024

)



######################################################################

# Left electrode parameters

######################################################################

left_electrode_electron_density_parameters = electronDensityParameters(

    mesh_cutoff = 400.0*Rydberg

)



left_electrode_iteration_control_parameters = iterationControlParameters(

    tolerance = 1e-005,

    criterion = IterationControl.TotalEnergy,

    max_steps = 100

)



left_electrode_brillouin_zone_integration_parameters = brillouinZoneIntegrationParameters(

    monkhorst_pack_parameters = (1, 1, 500)

)



left_electrode_iteration_mixing_parameters = iterationMixingParameters(

    algorithm = IterationMixing.Pulay,

    diagonal_mixing_parameter = 0.1,

    quantity = IterationMixing.Hamiltonian,

    history_steps = 6

)



left_electrode_eigenstate_occupation_parameters = eigenstateOccupationParameters(

    temperature = 300.0*Kelvin

)



######################################################################

# Collect left electrode parameters

######################################################################

left_electrode_parameters = ElectrodeParameters(

    brillouin_zone_integration_parameters = left_electrode_brillouin_zone_integration_parameters,

    electron_density_parameters = left_electrode_electron_density_parameters,

    eigenstate_occupation_parameters = left_electrode_eigenstate_occupation_parameters,

    iteration_mixing_parameters = left_electrode_iteration_mixing_parameters,

    iteration_control_parameters = left_electrode_iteration_control_parameters

)



######################################################################

# Right electrode parameters

######################################################################

right_electrode_electron_density_parameters = electronDensityParameters(

    mesh_cutoff = 400.0*Rydberg

)



right_electrode_iteration_control_parameters = iterationControlParameters(

    tolerance = 1e-005,

    criterion = IterationControl.TotalEnergy,

    max_steps = 100

)



right_electrode_brillouin_zone_integration_parameters = brillouinZoneIntegrationParameters(

    monkhorst_pack_parameters = (1, 1, 500)

)



right_electrode_iteration_mixing_parameters = iterationMixingParameters(

    algorithm = IterationMixing.Pulay,

    diagonal_mixing_parameter = 0.1,

    quantity = IterationMixing.Hamiltonian,

    history_steps = 6

)



right_electrode_eigenstate_occupation_parameters = eigenstateOccupationParameters(

    temperature = 300.0*Kelvin

)



######################################################################

# Collect right electrode parameters

######################################################################

right_electrode_parameters = ElectrodeParameters(

    brillouin_zone_integration_parameters = right_electrode_brillouin_zone_integration_parameters,

    electron_density_parameters = right_electrode_electron_density_parameters,

    eigenstate_occupation_parameters = right_electrode_eigenstate_occupation_parameters,

    iteration_mixing_parameters = right_electrode_iteration_mixing_parameters,

    iteration_control_parameters = right_electrode_iteration_control_parameters

)



######################################################################

# Initialize self-consistent field calculation

######################################################################

two_probe_method = TwoProbeMethod(

    electrode_parameters = (left_electrode_parameters,right_electrode_parameters),

    exchange_correlation_type = exchange_correlation_type,

    iteration_mixing_parameters = iteration_mixing_parameters,

    electron_density_parameters = electron_density_parameters,

    basis_set_parameters = basis_set_parameters,

    iteration_control_parameters = iteration_control_parameters,

    energy_contour_integral_parameters = energy_contour_integral_parameters,

    two_center_integral_parameters = two_center_integral_parameters,

    electrode_voltages = electrode_voltages,

    algorithm_parameters = two_probe_algorithm_parameters

)

if processIsMaster(): nlPrint(two_probe_method)



runtime_parameters = runtimeParameters(

    verbosity_level = 10,

    checkpoint_filename = '/home/hellboy/Desktop/NanoLab simulations/SWCNT 44 Two probe/SWCNT44twoprobe.nc'

)



voltages=[0.0,0.5,1.0]*Volt



ivcurve.runIVcurve (

    twoprobe_configuration,

    two_probe_method,

    runtime_parameters,

    voltages,

    vnl_filename='/home/hellboy/Desktop/NanoLab simulations/SWCNT 44 Two probe/SWCNT44twoprobe_iv.vnl', sample_name='/home/hellboy/Desktop/NanoLab simulations/SWCNT 44 Two probe/SWCNT44twoprobe',

    current_k_point_sampling = (1,1),

    current_number_of_points = 100

  )
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on September 1, 2010, 10:28
I feel it should create 3 checkpoint files ie., for 0v, 0.5V and 1.0V
I am not using voltage.arange and in windows it generates 3 netCDF files.
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on September 1, 2010, 10:32
Of course. My mistake, sorry.

Try not using spaces in your filenames...

What is the name of the file that is created on Linux? Is there some hints in the log file, does it actually run all 3 voltages?
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on September 1, 2010, 10:34
Also, try not using the full path of the file, just a local name (all files get written to the current directory anyway, if you run from the command line).
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on September 1, 2010, 10:39
I am not using spaces in filenames.
The name of the file created is SWCNT44twoprobe.nc in Linux
The size of single NetCDF file that is created in Linux is around 69MB, whereas the 3 NetCDF files that were created in Windows is 19.75 MB each

I will try with a local checkpoint file name and will not add full path.
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on September 1, 2010, 10:42
Well, there were spaces in the path name, that's what I meant :)

I'll check if there is some trivial mistake that only appears on Linux
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on September 1, 2010, 10:44
It did not completed run  for 3 voltages, my problem is that it must have created SWCNT44twoprob-0.0.nc then for other voltages.
But it created SWCNT44twoprobe.nc which is suspicious and that too of 69.5 MB size.
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on September 1, 2010, 10:56
I'm running some tests. Meanwhile, just a note: your "sample_name" for runIVcurve is not appropriate. You should set it to twoprobe_configuration to match the geometry.

Also, you may just as well lower the verbosity to 1 while testing. Did you check if indeed it runs all 3 voltages on Linux? What about the VNL file on Linux, do you have the current for all 3 voltages there?
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on September 1, 2010, 10:57
My initial tests show no problems. I'm getting a "SWCNT4twoprobe-0.0.nc" file already after the first electrode iteration on the zero-bias case.
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on September 1, 2010, 11:00
Sorry, didn't see your post before mine. Are you sure the SWCNT44twoprobe.nc file is not from another run? Try starting fresh in a new directory.

Check the ivcurve.py script, do you have the latest version? The magic line is

Code: python
new_filename = os.path.splitext(nc_filename)[0] + ('-%s' % voltage.inUnitsOf(Volt)) + os.path.splitext(nc_filename)[1]
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on September 1, 2010, 12:05
My run did not create SWCNT4twoprobe-0.0.nc so i stopped.
I have the latest ivscript.py with the "magic line"
Thank you for  "sample_name"  correction.
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on September 1, 2010, 12:18
I will try again taking your instructions into consideartion.
Thanks a lot for your prompt replies.
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on September 1, 2010, 12:33
I suggest you try a dry run, using the attached script instead of your existing ivcurve.py. That is, add this line

Code: python
import ivcurve_test as ivcurve

below the existing "import ivcurve" statement (you can keep that line) and let's see what it says.
Title: Re: Trouble Restarting from a checkpoint file
Post by: Anders Blom on September 1, 2010, 12:39
I think I know what the problem is!!!

As we can see from the test run, the PATH to the file is not kept. So, the NC files will be created in the current directory from where you run, and not where you asked it to be placed. To fix this, change the magic line to

Code: python
new_filename = path+"/"+os.path.splitext(nc_filename)[0] + ('-%s' % voltage.inUnitsOf(Volt)) + os.path.splitext(nc_filename)[1]

But probably somewhere on your system (/tmp?) there might be the NC files already...
Title: Re: Trouble Restarting from a checkpoint file
Post by: hellboy on September 2, 2010, 07:10
I haven't checked it with new "magic line"
I've rerun the script with no spacing in file names and also didn't specified the full path. Now I am able to get seperate NetCDF files in /bin folder of my ATK installation. VNL files are also generated in /bin folder.
I will soon try with the addition of "magic lines".

Thanks for your prompt responses.