TypeError: only length-1 arrays can be converted to Python
D.YAN ESCOLAR RAMBAL
dyeringamsa at gmail.com
Fri Sep 20 22:45:29 EDT 2013
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*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130920/fb769ec5/attachment.html>
More information about the Python-list
mailing list