Author Topic: Error in tutorial - unable to convert unit  (Read 4905 times)

0 Members and 1 Guest are viewing this topic.

Offline MariaWJ

  • Regular QuantumATK user
  • **
  • Posts: 8
  • Country: dk
  • Reputation: 0
    • View Profile
Error in tutorial - unable to convert unit
« on: July 28, 2021, 15:15 »
Hi there smart people. I am very new to QantumATK and not the master coder (so please dummy stuff down).  I have attempted to follow a tutorial from QATK's own webpage (https://docs.quantumatk.com/tutorials/atomic-scale_capacitance/atomic-scale_capacitance.html) but get an error when trying to run the electrostatic energy analysis to get the potential plot. I get an error saying "Unable to convert unit value V to an incompatible unit eV".

I have attached the python file I try to run and the error message as an text file. But again I am just following the tutorial and using their files.

Please can anyone help with a hopefully simple fix, is there maybe just a line I can add to convert the unit or ?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: Error in tutorial - unable to convert unit
« Reply #1 on: July 29, 2021, 09:01 »
Sorry about the typo. Since the tutorial was published we changed the definition of the ElectrostaticDifferencePotential class to be specified in V, not eV, as is appropriate for a "potential".

Thus, all you need to do is change line 51 (which the error message complains about) to

vv = -v_z[index].inUnitsOf(V)

There was also a sign change involved, I recall, hence the leading minus sign.

Offline MariaWJ

  • Regular QuantumATK user
  • **
  • Posts: 8
  • Country: dk
  • Reputation: 0
    • View Profile
Re: Error in tutorial - unable to convert unit
« Reply #2 on: July 29, 2021, 09:37 »
Hi there,

I did assume that was some part of it so I have tried to just change out the unit in line 51 (did not know about the change of sign). I now ran the script again with the change you suggested and it now says "NameError: name 'V' is not defined".

I then went ahead and tried out "Volt" as that clearly is used before, but that leaves a nasty error message too (which I have attached)

Do you know what is going wrong here? If it helps, then I am pretty sure I am running the 2020 version.

So far thank you :)
« Last Edit: July 29, 2021, 09:58 by MariaWJ »

Offline filipr

  • QuantumATK Staff
  • Heavy QuantumATK user
  • *****
  • Posts: 81
  • Country: dk
  • Reputation: 6
  • QuantumATK developer
    • View Profile
Re: Error in tutorial - unable to convert unit
« Reply #3 on: July 29, 2021, 12:23 »
The output is bloated with SLURM messages, however the important part is the error message:
Code
Traceback (most recent call last):
  File "potential_plot.py", line 70, in <module>
    axarr[1].plot(z.inUnitsOf(Ang), v_z.inUnitsOf(eV))
  File "zipdir/NL/CommonConcepts/PhysicalQuantity.py", line 2173, in inUnitsOf
NL.ComputerScienceUtilities.Exceptions.NLValueError: Unable to convert unit value V to an incompatible unit eV.
So I guess you still have to use volts for the potential v_z, i.e. change line 70 in your script to:
Code
axarr[1].plot(z.inUnitsOf(Ang), v_z.inUnitsOf(Volt))

Offline MariaWJ

  • Regular QuantumATK user
  • **
  • Posts: 8
  • Country: dk
  • Reputation: 0
    • View Profile
Re: Error in tutorial - unable to convert unit
« Reply #4 on: July 29, 2021, 12:53 »
Oh my... IT WORKED!

Thank you so much for the help, it is very appreciated :)
Now I will continue the tutorial, hopefully without more trouble (fingers crossed).

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5576
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: Error in tutorial - unable to convert unit
« Reply #5 on: July 30, 2021, 00:01 »
Sorry for not catching these basic things, I should have checked more carefully Volt of course, and thank Filip for the plotting part - I thought we converted the unit once only.