Thank you all, for your hints. I *will* try to stop posting and fix my code with your suggestions.
Bests
Die Suche ergab 6 Treffer
- Donnerstag 21. März 2013, 15:43
- Forum: Allgemeine Fragen
- Thema: A simple code problem
- Antworten: 12
- Zugriffe: 1229
- Donnerstag 21. März 2013, 15:33
- Forum: Allgemeine Fragen
- Thema: A simple code problem
- Antworten: 12
- Zugriffe: 1229
Re: A simple code problem
@Homer.Simpson:
`r = pylab.arange(10.0, 20000.0, dr)` is the very first line in your function. At that time Python does not know about the name `dr`. But it is used for the definition of `r`. This is why the error is thrown.
Thanks for your replay. But can you first have a look in to one post ...
`r = pylab.arange(10.0, 20000.0, dr)` is the very first line in your function. At that time Python does not know about the name `dr`. But it is used for the definition of `r`. This is why the error is thrown.
Thanks for your replay. But can you first have a look in to one post ...
- Donnerstag 21. März 2013, 15:19
- Forum: Allgemeine Fragen
- Thema: A simple code problem
- Antworten: 12
- Zugriffe: 1229
Re: A simple code problem
@Homer.Simpson: No you didn't. The only line where you assigned something to that name is line 38 and that ist 8 lines *after* you tried to use it the first time.
You are right. But I don't use it till I define it in line 38 (or better to say 39). I define "r" in line 31, but the code doesn't ...
You are right. But I don't use it till I define it in line 38 (or better to say 39). I define "r" in line 31, but the code doesn't ...
- Donnerstag 21. März 2013, 14:40
- Forum: Allgemeine Fragen
- Thema: A simple code problem
- Antworten: 12
- Zugriffe: 1229
Re: A simple code problem
Hi \me/me hat geschrieben: The error is quite clear.You use dr, but you haven't defined it before trying to use it.Code: Alles auswählen
r = pylab.arange(10.0, 20000.0, dr)
It is not true, if you have a look in to line 34 I have defined it before using it.
- Donnerstag 21. März 2013, 14:36
- Forum: Allgemeine Fragen
- Thema: A simple code problem
- Antworten: 12
- Zugriffe: 1229
Re: A simple code problem
Sorry guys for inappropriate style
. In fact I'm new in python or in other words I do not write in python. I need to run this code to understand the physics behind it.
I will try to fix the point which you have mentioned.
Bests
I will try to fix the point which you have mentioned.
Bests
- Donnerstag 21. März 2013, 14:15
- Forum: Allgemeine Fragen
- Thema: A simple code problem
- Antworten: 12
- Zugriffe: 1229
A simple code problem
Hi everybody
I have a simple code as follow:
import pylab
from scipy.integrate import odeint
from scipy.constants import pi, G, c, hbar, m_n
Msun=1.98892e30
Gamma0 = 5.0/3.0
K0 = (3.0*pi**2)**(2.0/3.0)*hbar**2/(5.0*m_n**(8.0/3.0))
Gamma1 = 3
rho1 = 5e17
P1 = K0*rho1**Gamma0
K1 = P1/rho1 ...
I have a simple code as follow:
import pylab
from scipy.integrate import odeint
from scipy.constants import pi, G, c, hbar, m_n
Msun=1.98892e30
Gamma0 = 5.0/3.0
K0 = (3.0*pi**2)**(2.0/3.0)*hbar**2/(5.0*m_n**(8.0/3.0))
Gamma1 = 3
rho1 = 5e17
P1 = K0*rho1**Gamma0
K1 = P1/rho1 ...
