hay
I try to write a py script to calculate something for me. The script
is called friction.py and containes
#!/usr/bin/env sage -python
import sys
from sage.all import *
import functions
from functions import *
print "Ok... dann legen wir mal los!\n"
print "step1: definition of the density profile"
r = 1.
print rho(r),"\n"
print "step2: definition of the circular velocity"
print cirvelo(0.6)
the functiones used in this script are defined in a separate file
called functions.py
import sys
from sage.all import *
def rho(r):
return 1.32419e+08/(1.+(r/0.81))**3
def cirvelo(r):
grav_const = 4.3e-06
pi = 3.14159265358979323846
i_term = integral(x**2*rho(x), x, 0, r)
return (4.*pi*grav_const*i_term/r)**(0.5)
if I run the script I get an error message which reefers to the x in
the calculation of the integral
flor...@base:~/sage/sage-3.4$ ./sage friction.py
Ok... dann legen wir mal los!
step1: definition of the density profile
11867784.07
step2: definition of the circular velocity
Traceback (most recent call last):
File "friction.py", line 18, in <module>
print cirvelo(0.6)
File "/home/florian/sage/sage-3.4/functions.py", line 11, in cirvelo
i_term = integral(x**2*rho(x), x, 0, r)
NameError: global name 'x' is not defined
if I run a similar integral directly in sage it works very well, so I
probably forgot anything to include??
thanks for help
regards
florian
p.s. is there any good tutorial for writing sage scripts? The tutorial
I found in the web are focused on sage itself and script things are
not well explained
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---