-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble running on mac terminal #2
Comments
Hi! Thanks for mentioning the french accent I didn't know this could be a problem!:) It is weird that it isn't working because I am also running the code on a mac terminal. I'm also pretty surprised that you get error of the kind "Variable concavity is referenced before assignment in Fct_Numerov.py." with seems like a fundamental problem in the code and not just a compatibility problem because I've run the code on my computer this morning (with a harmonic potential) and everything seems to be working fine. I have looked to see if the repository was up to date and the only file that wasn't up to date was the README so the code should normally be working. I remember that I already had problems of this kind with earlier version of the code. Are you using the actual version of the code? And just to be sure, are you using python 3 or python 2? Also how are you entering the potential? Maybe there is some error on how the program is interpreting the input because the errors you get seem to be in the beginning of the code when the program verifies that the input is a valid potential. For an harmonic potential the input should just be "x**2". If it still isn't working send me an example all the messages you have when you are running the code. Félix |
Hi Felix,
I am using python 2 (Canopy).
"Variable concavity is referenced before assignment in Fct_Numerov.py"
error is given because the assignment is done in if condition, i.e. when
the if condition isn't met, the variable is referenced without being
assigned. I fixed it by assigning it a dummy value "nan" in the same
function.
The if condition wasn't being met because of 1/500000 term (in
GetFirstEnergyGuess function) was being interpreted as 0 in my case. I
changed it, as you see in "git diff" below:
@@ -165,8 +165,7 @@ def GetFirstEnergyGuess(PotentialArray):
potential times 1/50000
"""
-
- First_E_guess = PotentialArray.min() + (1/500000) *
(PotentialArray.mean() + PotentialArray.min())
+ First_E_guess = PotentialArray.min() + (1.0/500000) *
(PotentialArray.mean() + PotentialArray.min())
Then, the concavity variable was being set to "positive". I am using the
latest version of the code, as of April 24, 2018.
Below is the error I get now:
('E_guess: ', 171.53334966311712)
Resetting the energy guess!
('E_guess: ', 170.21386235801623)
Resetting the energy guess!
('E_guess: ', 169.55411870546578)
Resetting the energy guess!
('E_guess: ', 169.22424687919056)
Resetting the energy guess!
('E_guess: ', 169.05931096605295)
Resetting the energy guess!
('E_guess: ', 168.97684300948413)
Traceback (most recent call last):
File "numerov.py", line 205, in <module>
y_max,min_x,max_x,WavPlot,WavLines,EnergyLines =
Fct_Numerov.DefineWhatToPlot(WaveFunctionFound,EnergyLevelFound)
File "/Users/alishsan/Documents/DWBA/Numerov/Fct_Numerov.py", line 707,
in DefineWhatToPlot
y_max = 1.1*EnergyLevelFound[max(EnergyLevelFound)]
ValueError: max() arg is an empty sequence
…On Fri, May 4, 2018 at 9:50 PM, Félix Desrochers ***@***.***> wrote:
Hi!
Thanks for mentioning the french accent I didn't know this could be a
problem!:)
It is weird that it isn't working because I am also running the code on a
mac terminal. I'm also pretty surprised that you get error of the kind
"Variable concavity is referenced before assignment in Fct_Numerov.py."
with seems like a fundamental problem in the code and not just a
compatibility problem because I've run the code on my computer this morning
(with a harmonic potential) and everything seems to be working fine.
I have looked to see if the repository was up to date and the only file
that wasn't up to date was the README so the code should normally be
working.
I remember that I already had problems of this kind with earlier version
of the code. Are you using the actual version of the code? And just to be
sure, are you using python 3 or python 2?
Also how are you entering the potential? Maybe there is some error on how
the program is interpreting the input because the errors you get seem to be
in the beginning of the code when the program verifies that the input is a
valid potential. For an harmonic potential the input should just be "x**2".
If it still isn't working send me an example all the messages you have
when you are running the code.
Félix
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_FelixDesrochers_Numerov_issues_2-23issuecomment-2D386661460&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=aMihuDtVZoRM3r8VwjvNoQ&m=0LYhhAKT1ijW07qaqImRQ1i98Np5SCe4cRW5e6d1tHw&s=AVzjuwnP8D1q1sFBGuX4CccZIyVMc0C33Q-JwBrPhlU&e=>,
or mute the thread
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AEEjKqi8I3QuOOJmwkBIlBCpgC6rOMD4ks5tvIbygaJpZM4TwwH0&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=aMihuDtVZoRM3r8VwjvNoQ&m=0LYhhAKT1ijW07qaqImRQ1i98Np5SCe4cRW5e6d1tHw&s=qsir7pwXDyfWSzDxWrsNsGjKF8OD5JdBdC1H1FvBtWY&e=>
.
|
The potential is alright, but I had to enter it as a string, with quote
signs ' '. I have now hardcoded the 'x**2' potential in the code (so I
don't have to enter it every time), and even had the code plot the
potential. It looks like a harmonic
potential, I have attached the figure.
On Fri, May 4, 2018 at 10:37 PM, Alisher Sanetullaev <[email protected]>
wrote:
… Hi Felix,
I am using python 2 (Canopy).
"Variable concavity is referenced before assignment in Fct_Numerov.py"
error is given because the assignment is done in if condition, i.e. when
the if condition isn't met, the variable is referenced without being
assigned. I fixed it by assigning it a dummy value "nan" in the same
function.
The if condition wasn't being met because of 1/500000 term (in
GetFirstEnergyGuess function) was being interpreted as 0 in my case. I
changed it, as you see in "git diff" below:
@@ -165,8 +165,7 @@ def GetFirstEnergyGuess(PotentialArray):
potential times 1/50000
"""
-
- First_E_guess = PotentialArray.min() + (1/500000) *
(PotentialArray.mean() + PotentialArray.min())
+ First_E_guess = PotentialArray.min() + (1.0/500000) *
(PotentialArray.mean() + PotentialArray.min())
Then, the concavity variable was being set to "positive". I am using the
latest version of the code, as of April 24, 2018.
Below is the error I get now:
('E_guess: ', 171.53334966311712)
Resetting the energy guess!
('E_guess: ', 170.21386235801623)
Resetting the energy guess!
('E_guess: ', 169.55411870546578)
Resetting the energy guess!
('E_guess: ', 169.22424687919056)
Resetting the energy guess!
('E_guess: ', 169.05931096605295)
Resetting the energy guess!
('E_guess: ', 168.97684300948413)
Traceback (most recent call last):
File "numerov.py", line 205, in <module>
y_max,min_x,max_x,WavPlot,WavLines,EnergyLines =
Fct_Numerov.DefineWhatToPlot(WaveFunctionFound,EnergyLevelFound)
File "/Users/alishsan/Documents/DWBA/Numerov/Fct_Numerov.py", line 707,
in DefineWhatToPlot
y_max = 1.1*EnergyLevelFound[max(EnergyLevelFound)]
ValueError: max() arg is an empty sequence
On Fri, May 4, 2018 at 9:50 PM, Félix Desrochers ***@***.***
> wrote:
> Hi!
>
> Thanks for mentioning the french accent I didn't know this could be a
> problem!:)
>
> It is weird that it isn't working because I am also running the code on a
> mac terminal. I'm also pretty surprised that you get error of the kind
> "Variable concavity is referenced before assignment in Fct_Numerov.py."
> with seems like a fundamental problem in the code and not just a
> compatibility problem because I've run the code on my computer this morning
> (with a harmonic potential) and everything seems to be working fine.
>
> I have looked to see if the repository was up to date and the only file
> that wasn't up to date was the README so the code should normally be
> working.
>
> I remember that I already had problems of this kind with earlier version
> of the code. Are you using the actual version of the code? And just to be
> sure, are you using python 3 or python 2?
>
> Also how are you entering the potential? Maybe there is some error on how
> the program is interpreting the input because the errors you get seem to be
> in the beginning of the code when the program verifies that the input is a
> valid potential. For an harmonic potential the input should just be "x**2".
>
> If it still isn't working send me an example all the messages you have
> when you are running the code.
>
> Félix
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_FelixDesrochers_Numerov_issues_2-23issuecomment-2D386661460&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=aMihuDtVZoRM3r8VwjvNoQ&m=0LYhhAKT1ijW07qaqImRQ1i98Np5SCe4cRW5e6d1tHw&s=AVzjuwnP8D1q1sFBGuX4CccZIyVMc0C33Q-JwBrPhlU&e=>,
> or mute the thread
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AEEjKqi8I3QuOOJmwkBIlBCpgC6rOMD4ks5tvIbygaJpZM4TwwH0&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=aMihuDtVZoRM3r8VwjvNoQ&m=0LYhhAKT1ijW07qaqImRQ1i98Np5SCe4cRW5e6d1tHw&s=qsir7pwXDyfWSzDxWrsNsGjKF8OD5JdBdC1H1FvBtWY&e=>
> .
>
|
The x-axis in the potential plot is actually index (0 to 8000), not x. I
ran a "git status" now:
git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Fct_Numerov.py
modified: Numerov.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
#numerov.py#
Fct_Numerov.pyc
Schrod.gif
On Fri, May 4, 2018 at 10:51 PM, Alisher Sanetullaev <[email protected]>
wrote:
… The potential is alright, but I had to enter it as a string, with quote
signs ' '. I have now hardcoded the 'x**2' potential in the code (so I
don't have to enter it every time), and even had the code plot the
potential. It looks like a harmonic
potential, I have attached the figure.
On Fri, May 4, 2018 at 10:37 PM, Alisher Sanetullaev ***@***.***>
wrote:
> Hi Felix,
>
> I am using python 2 (Canopy).
>
> "Variable concavity is referenced before assignment in Fct_Numerov.py"
> error is given because the assignment is done in if condition, i.e. when
> the if condition isn't met, the variable is referenced without being
> assigned. I fixed it by assigning it a dummy value "nan" in the same
> function.
>
> The if condition wasn't being met because of 1/500000 term (in
> GetFirstEnergyGuess function) was being interpreted as 0 in my case. I
> changed it, as you see in "git diff" below:
>
> @@ -165,8 +165,7 @@ def GetFirstEnergyGuess(PotentialArray):
>
> potential times 1/50000
>
>
>
> """
>
> -
>
> - First_E_guess = PotentialArray.min() + (1/500000) *
> (PotentialArray.mean() + PotentialArray.min())
>
> + First_E_guess = PotentialArray.min() + (1.0/500000) *
> (PotentialArray.mean() + PotentialArray.min())
>
>
>
> Then, the concavity variable was being set to "positive". I am using the
> latest version of the code, as of April 24, 2018.
>
> Below is the error I get now:
>
> ('E_guess: ', 171.53334966311712)
>
> Resetting the energy guess!
>
>
> ('E_guess: ', 170.21386235801623)
>
> Resetting the energy guess!
>
>
> ('E_guess: ', 169.55411870546578)
>
> Resetting the energy guess!
>
>
> ('E_guess: ', 169.22424687919056)
>
> Resetting the energy guess!
>
>
> ('E_guess: ', 169.05931096605295)
>
> Resetting the energy guess!
>
>
> ('E_guess: ', 168.97684300948413)
>
> Traceback (most recent call last):
>
> File "numerov.py", line 205, in <module>
>
> y_max,min_x,max_x,WavPlot,WavLines,EnergyLines =
> Fct_Numerov.DefineWhatToPlot(WaveFunctionFound,EnergyLevelFound)
>
> File "/Users/alishsan/Documents/DWBA/Numerov/Fct_Numerov.py", line
> 707, in DefineWhatToPlot
>
> y_max = 1.1*EnergyLevelFound[max(EnergyLevelFound)]
>
> ValueError: max() arg is an empty sequence
>
> On Fri, May 4, 2018 at 9:50 PM, Félix Desrochers <
> ***@***.***> wrote:
>
>> Hi!
>>
>> Thanks for mentioning the french accent I didn't know this could be a
>> problem!:)
>>
>> It is weird that it isn't working because I am also running the code on
>> a mac terminal. I'm also pretty surprised that you get error of the kind
>> "Variable concavity is referenced before assignment in Fct_Numerov.py."
>> with seems like a fundamental problem in the code and not just a
>> compatibility problem because I've run the code on my computer this morning
>> (with a harmonic potential) and everything seems to be working fine.
>>
>> I have looked to see if the repository was up to date and the only file
>> that wasn't up to date was the README so the code should normally be
>> working.
>>
>> I remember that I already had problems of this kind with earlier version
>> of the code. Are you using the actual version of the code? And just to be
>> sure, are you using python 3 or python 2?
>>
>> Also how are you entering the potential? Maybe there is some error on
>> how the program is interpreting the input because the errors you get seem
>> to be in the beginning of the code when the program verifies that the input
>> is a valid potential. For an harmonic potential the input should just be
>> "x**2".
>>
>> If it still isn't working send me an example all the messages you have
>> when you are running the code.
>>
>> Félix
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub
>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_FelixDesrochers_Numerov_issues_2-23issuecomment-2D386661460&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=aMihuDtVZoRM3r8VwjvNoQ&m=0LYhhAKT1ijW07qaqImRQ1i98Np5SCe4cRW5e6d1tHw&s=AVzjuwnP8D1q1sFBGuX4CccZIyVMc0C33Q-JwBrPhlU&e=>,
>> or mute the thread
>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AEEjKqi8I3QuOOJmwkBIlBCpgC6rOMD4ks5tvIbygaJpZM4TwwH0&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=aMihuDtVZoRM3r8VwjvNoQ&m=0LYhhAKT1ijW07qaqImRQ1i98Np5SCe4cRW5e6d1tHw&s=qsir7pwXDyfWSzDxWrsNsGjKF8OD5JdBdC1H1FvBtWY&e=>
>> .
>>
>
>
|
Okay, now the code can find correct wavefunctions (but after that it gets
stuck in matplotlib part). The culprit again is type conversion, or lack
thereof, here is a part of git diff output
(green is my change, red is what changed). I replaced 1/12 by 1./12 and
5/12 by 5.12. Also, I changed the name of OuputEnergy function to
OutputEnergy:
@@ -511,7 +511,7 @@ def WaveFunctionNumerov(potential, E_guess,
nbr_division, Initial_augmentation,
k_2_minus1 = 2 * (E_guess - V_minus1)
#Calculating the wave function
- psi = ((2 * (1 - (5/12) * (Division**2) * (k_2)) *
(WaveFunction[-1][1])) - (1 + (1/12) * (Division**2) * k_2_minus1 )
+ psi = ((2 * (1. - (5./12) * (Division**2) * (k_2)) *
(WaveFunction[-1][1])) - (1. + (1./12) * (Division**2) * k_2_minus
#Saving the wave function and the x coordinate
WaveFunction.append((i,psi))
@@ -671,12 +671,12 @@ def SaveEnergy(NumberOfNodes, E_guess, E_guess_try):
#####################################
-# 3) Ouput (Energy levels and figure)
+# 3) Output (Energy levels and figure)
####################################
#############################
-# i) ouput the energy levels
…-def OuputEnergy(EnergyLevelFound):
+# i) output the energy levels
+def OutputEnergy(EnergyLevelFound):
for i,Energy in EnergyLevelFound.items():
print('Energy level', i, ':', Energy)
On Fri, May 4, 2018 at 11:01 PM, Alisher Sanetullaev <[email protected]>
wrote:
The x-axis in the potential plot is actually index (0 to 8000), not x. I
ran a "git status" now:
git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Fct_Numerov.py
modified: Numerov.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
#numerov.py#
Fct_Numerov.pyc
Schrod.gif
On Fri, May 4, 2018 at 10:51 PM, Alisher Sanetullaev ***@***.***>
wrote:
> The potential is alright, but I had to enter it as a string, with quote
> signs ' '. I have now hardcoded the 'x**2' potential in the code (so I
> don't have to enter it every time), and even had the code plot the
> potential. It looks like a harmonic
> potential, I have attached the figure.
>
>
> On Fri, May 4, 2018 at 10:37 PM, Alisher Sanetullaev ***@***.***>
> wrote:
>
>> Hi Felix,
>>
>> I am using python 2 (Canopy).
>>
>> "Variable concavity is referenced before assignment in Fct_Numerov.py"
>> error is given because the assignment is done in if condition, i.e. when
>> the if condition isn't met, the variable is referenced without being
>> assigned. I fixed it by assigning it a dummy value "nan" in the same
>> function.
>>
>> The if condition wasn't being met because of 1/500000 term (in
>> GetFirstEnergyGuess function) was being interpreted as 0 in my case. I
>> changed it, as you see in "git diff" below:
>>
>> @@ -165,8 +165,7 @@ def GetFirstEnergyGuess(PotentialArray):
>>
>> potential times 1/50000
>>
>>
>>
>> """
>>
>> -
>>
>> - First_E_guess = PotentialArray.min() + (1/500000) *
>> (PotentialArray.mean() + PotentialArray.min())
>>
>> + First_E_guess = PotentialArray.min() + (1.0/500000) *
>> (PotentialArray.mean() + PotentialArray.min())
>>
>>
>>
>> Then, the concavity variable was being set to "positive". I am using the
>> latest version of the code, as of April 24, 2018.
>>
>> Below is the error I get now:
>>
>> ('E_guess: ', 171.53334966311712)
>>
>> Resetting the energy guess!
>>
>>
>> ('E_guess: ', 170.21386235801623)
>>
>> Resetting the energy guess!
>>
>>
>> ('E_guess: ', 169.55411870546578)
>>
>> Resetting the energy guess!
>>
>>
>> ('E_guess: ', 169.22424687919056)
>>
>> Resetting the energy guess!
>>
>>
>> ('E_guess: ', 169.05931096605295)
>>
>> Resetting the energy guess!
>>
>>
>> ('E_guess: ', 168.97684300948413)
>>
>> Traceback (most recent call last):
>>
>> File "numerov.py", line 205, in <module>
>>
>> y_max,min_x,max_x,WavPlot,WavLines,EnergyLines =
>> Fct_Numerov.DefineWhatToPlot(WaveFunctionFound,EnergyLevelFound)
>>
>> File "/Users/alishsan/Documents/DWBA/Numerov/Fct_Numerov.py", line
>> 707, in DefineWhatToPlot
>>
>> y_max = 1.1*EnergyLevelFound[max(EnergyLevelFound)]
>>
>> ValueError: max() arg is an empty sequence
>>
>> On Fri, May 4, 2018 at 9:50 PM, Félix Desrochers <
>> ***@***.***> wrote:
>>
>>> Hi!
>>>
>>> Thanks for mentioning the french accent I didn't know this could be a
>>> problem!:)
>>>
>>> It is weird that it isn't working because I am also running the code on
>>> a mac terminal. I'm also pretty surprised that you get error of the kind
>>> "Variable concavity is referenced before assignment in Fct_Numerov.py."
>>> with seems like a fundamental problem in the code and not just a
>>> compatibility problem because I've run the code on my computer this morning
>>> (with a harmonic potential) and everything seems to be working fine.
>>>
>>> I have looked to see if the repository was up to date and the only file
>>> that wasn't up to date was the README so the code should normally be
>>> working.
>>>
>>> I remember that I already had problems of this kind with earlier
>>> version of the code. Are you using the actual version of the code? And just
>>> to be sure, are you using python 3 or python 2?
>>>
>>> Also how are you entering the potential? Maybe there is some error on
>>> how the program is interpreting the input because the errors you get seem
>>> to be in the beginning of the code when the program verifies that the input
>>> is a valid potential. For an harmonic potential the input should just be
>>> "x**2".
>>>
>>> If it still isn't working send me an example all the messages you have
>>> when you are running the code.
>>>
>>> Félix
>>>
>>> —
>>> You are receiving this because you authored the thread.
>>> Reply to this email directly, view it on GitHub
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_FelixDesrochers_Numerov_issues_2-23issuecomment-2D386661460&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=aMihuDtVZoRM3r8VwjvNoQ&m=0LYhhAKT1ijW07qaqImRQ1i98Np5SCe4cRW5e6d1tHw&s=AVzjuwnP8D1q1sFBGuX4CccZIyVMc0C33Q-JwBrPhlU&e=>,
>>> or mute the thread
>>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AEEjKqi8I3QuOOJmwkBIlBCpgC6rOMD4ks5tvIbygaJpZM4TwwH0&d=DwMFaQ&c=nE__W8dFE-shTxStwXtp0A&r=aMihuDtVZoRM3r8VwjvNoQ&m=0LYhhAKT1ijW07qaqImRQ1i98Np5SCe4cRW5e6d1tHw&s=qsir7pwXDyfWSzDxWrsNsGjKF8OD5JdBdC1H1FvBtWY&e=>
>>> .
>>>
>>
>>
>
|
Hi,
I have been trying to use the code on a mac terminal, the interpreter keeps giving me error codes.
First was character encoding problems, like the French accents in your name. :) So I had to change your name to Felix from Félix. :)
Some errors had to do with typesetting, like, (1/500000) gets turned into integer 0 in my case, instead of a float.
Variable concavity is referenced before assignment in Fct_Numerov.py.
Now I am trying get the code working with harmonic potential, to no avail. The energy guessing part is not working correctly, frustratingly.
The text was updated successfully, but these errors were encountered: