QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: yasheng on August 1, 2016, 17:32

Title: "IndentationError: unexpected indent" with ATK 2016
Post by: yasheng on August 1, 2016, 17:32
Dear All,
My first calculation with ATK 2016 version ended with some unexpected error.

IndentationError: unexpected indent
 File "6_Cu111.py", line 149
 element=PeriodicTable.Oxygen,

Does anyone have similar problem? I've never seen this type of error with 2015 version.

I don't know what caused this indentation error. please help me.

Regards,
Yasheng







Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: Anders Blom on August 1, 2016, 17:38
Simple Python error, but can only be solved by showing your script
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: yasheng on August 2, 2016, 10:28
Thank you for your reply. I attached the script for your inspection.

Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: yasheng on August 2, 2016, 15:17
Now it is clear that this is because of the bug in VNL 2016 script generator.

VNL 2016 script generator produce the following script for OPENMX basis set

#----------------------------------------
# Basis Set
#----------------------------------------
# Basis set for OxygenOxygenBasis = OpenMXBasisSet(
    element=PeriodicTable.Oxygen,
    filename="openmx/pao/O7.0.pao.zip",
    atomic_species="s2p2d1",
    hubbard_u=[0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    filling_method=SphericalSymmetric,
    onsite_spin_orbit_split=[0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    pseudopotential=NormConservingPseudoPotential("normconserving/upf2/O_CA13.upf.zip"),
    )


# Basis set for CopperCopperBasis = OpenMXBasisSet(
    element=PeriodicTable.Copper,
    filename="openmx/pao/Cu6.0H.pao.zip",
    atomic_species="s3p2d1",
    hubbard_u=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    filling_method=SphericalSymmetric,
    onsite_spin_orbit_split=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    pseudopotential=NormConservingPseudoPotential("normconserving/upf2/Cu_CA13H.upf.zip"),
    )




it should be another line after "# Basis set for Oxygen/Copper". e.g:



#----------------------------------------
# Basis Set
#----------------------------------------
# Basis set for Oxygen
OxygenBasis = OpenMXBasisSet(
    element=PeriodicTable.Oxygen,
    filename="openmx/pao/O7.0.pao.zip",
    atomic_species="s2p2d1",
    hubbard_u=[0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    filling_method=SphericalSymmetric,
    onsite_spin_orbit_split=[0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    pseudopotential=NormConservingPseudoPotential("normconserving/upf2/O_CA13.upf.zip"),
    )


# Basis set for Copper
CopperBasis = OpenMXBasisSet(
    element=PeriodicTable.Copper,
    filename="openmx/pao/Cu6.0H.pao.zip",
    atomic_species="s3p2d1",
    hubbard_u=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    filling_method=SphericalSymmetric,
    onsite_spin_orbit_split=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    pseudopotential=NormConservingPseudoPotential("normconserving/upf2/Cu_CA13H.upf.zip"),
    )



I hope this bug be fixed as soon as possible.

Regards,
Yasheng




Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: Umberto Martinez on August 3, 2016, 10:03
Not a bug.
the lines should read:

Code
OxygenOxygenBasis = OpenMXBasisSet(
    element=PeriodicTable.Oxygen,
    filename="openmx/pao/O7.0.pao.zip",
    atomic_species="s2p2d1",
    hubbard_u=[0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    filling_method=SphericalSymmetric,
    onsite_spin_orbit_split=[0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    pseudopotential=NormConservingPseudoPotential("normconserving/upf2/O_CA13.upf.zip"),
    )

same for the CopperCopperBasis definition.

Also, next time please attach the full script.
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: asanchez on August 3, 2016, 18:03
I believe there is a bug.

To reproduce this you need to select the OpenMX basis set and then set "Script detail" to "Show defaults". The resulting script generated by VNL2016 will have that mistake.

It seems to only happen with OpenMX basis sets and only when you select "show defaults" - which introduces the comment "# Basis set for X". There doesn't seem to be a line break after the comment.
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: yasheng on August 3, 2016, 21:06
Yes,  I have already posted the full script. (just scroll up little bit, and you can see the attachment)
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: Umberto Martinez on August 3, 2016, 21:50
missed the part mentioning the script generator!! ?? sorry. my mistake, indeed it seems like a bug.
plus I even wrote it wrong, you should break the line after the first Oxygen:
Code
# Basis set for Oxygen
OxygenBasis = OpenMXBasisSet(
    element=PeriodicTable.Oxygen,
    filename="openmx/pao/O7.0.pao.zip",
    atomic_species="s2p2d1",
    hubbard_u=[0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    filling_method=SphericalSymmetric,
    onsite_spin_orbit_split=[0.0, 0.0, 0.0, 0.0, 0.0]*eV,
    pseudopotential=NormConservingPseudoPotential("normconserving/upf2/O_CA13.upf.zip"),
    )

thank you both for reporting it, we'll keep you posted!
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: Anders Blom on August 4, 2016, 19:38
As a temporary workaround for running calculations with the OMX basis sets and begin able to read back the results, make sure you save the configuration in a separate NC file, different from the analysis objects.
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: yasheng on August 16, 2016, 17:12
After manually correcting the OMX basis set part of the script and calculating the electrodes separately, I found that the electrodes cannot be re-used to calculate the transmission of the device.

This is because of the same bug and the produced nc file have some problem even if I correct the script. What a waste of time, I should go back to 2015 version. 
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: Anders Blom on August 17, 2016, 08:13
It's a very unfortunate bug and therefore we are moving fast to release 2016.1 which fixes it. It will hopefully be available within the next few days.

The workarounds do not really work for devices, I admit, since the error is rather fundamental (although, it would work for bulk, to at least get the calculation through and be able to inspect some results).

The problem only occurs for OMX basis sets - maybe you would like to try the new SG15 sets instead? They give very accurate results, are softer than OMX, so you need small cutoffs, and they also support spin-orbit.

Anyway, we apologize for the inconvenience, and hope you will enjoy 2016.1 very soon!
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: yasheng on August 17, 2016, 11:45
That is a good news! I look forward the release of 2016.1 and fixing all these bugs.

I used OMX basis sets for my previous calculations, and I think I should probably stick to that for the sake of consistency.
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: Jess Wellendorff on August 17, 2016, 11:47
Yes, that makes good sense.
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: Umberto Martinez on September 19, 2016, 10:39
In case you missed the news, ATK 2016.1 has been released where this issue with OMX basis set is fixed + support has been added for opening broken NC files produced by 2016.0 (in case you manually fixed the script problem).

http://quantumwise.com/products/download
Title: Re: "IndentationError: unexpected indent" with ATK 2016
Post by: creigelde on November 26, 2019, 07:49
As the error message indicates, you have an unexpected indent (http://net-informations.com/python/err/indent.htm) error. This error occurs when a statement is unnecessarily indented or its indentation does not match the indentation of former statements in the same block. Python not only insists on indentation, it insists on consistent indentation . You are free to choose the number of spaces of indentation to use, but you then need to stick with it. If you indent one line by 4 spaces, but then indent the next by 2 (or 5, or 10, or ...), you'll get this error. Whenever you have a situation with code inside of a statement, that inside code must be indented, and must be indented consistently. It is used by the interpreter to know how to delimit blocks of instructions.