Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54535
| Date | 2013-09-20 21:45 -0500 |
|---|---|
| Subject | TypeError: only length-1 arrays can be converted to Python |
| From | "D.YAN ESCOLAR RAMBAL" <dyeringamsa@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.218.1379745528.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
this the code,
______________________________________________________________
import math
import numexpr as ne
import matplotlib.pyplot as plt
import numpy as np
import numba as nb
M = 10
A = 10
D = 0.1
xmin = -4
xmax = 4
n = 800
tfinal = 3
tinicial = 1
# GENERANDO VECTOR CON PUNTOS DE DISCRETIZACION X ESPACIADOS
x= np.linspace(xmin, xmax, n)
#GENERANDO FUNCION ANALITICA
def Cdifuana(M,A,D,x,t):
temp = A*math.sqrt(4*math.pi*D*t);
Cdifuana = (M/temp)*math.exp(-x**2 /(4*D*t))
#GENERANDO CONDICION INICIAL
C=(Cdifuana(M,A,D,x,tinicial))
___________________________________________________________
In this code, I try obtain graph comparative the analytic and numerical
solution for the diffusion equation in 1D, but whe I define the analytic
function, run the phase, the compilator show me this message.
Traceback (most recent call last):
File "D:\Yan\Documents\Aptana Studio 3 Workspace\DIF1DMEDYER\SOLUCION
NUMERICA PARA LA ECUACION DE LA DIFUSION EN 1D DYER", line 34, in <module>
C=(Cdifuana(M,A,D,x,tinicial))
File "D:\Yan\Documents\Aptana Studio 3 Workspace\DIF1DMEDYER\SOLUCION
NUMERICA PARA LA ECUACION DE LA DIFUSION EN 1D DYER", line 32, in Cdifuana
Cdifuana = (M/temp)*math.exp(-x**2 /(4*D*t))
TypeError: only length-1 arrays can be converted to Python
--
*Gracias, cordialmente, *
*
*
*
*
*ING. YANETH ESCOLAR RAMBAL*
*HAFI Engineering & Consulting GmbH*
*CEL: + 57 3166257245*
*TEL: + 57 (1) 6508308*
*TEL: ++43 5522 77924 0*
*Fax: ++43 5522 74938*
*Dir : Cll 72f no. 113-21 Torre 5 - 604 Bogotá Colombia*
* Muehletorplatz 4-6, A-6800 Feldkirch, Austria*
*www.hafi.cc/en/environ_en.htm*
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
TypeError: only length-1 arrays can be converted to Python "D.YAN ESCOLAR RAMBAL" <dyeringamsa@gmail.com> - 2013-09-20 21:45 -0500
csiph-web