-4
です。そのコードは、過去の現在と未来が3行であった3xNの次元行列用です。私は高速な計算のためにそれを1次元配列に変更しました。どこが間違ってインデックス1は、軸0の範囲外であり、サイズは1で、マトリックスは
psi_past_real = np.zeros((1,domain)) # real part 3xN matrix
psi_past_imaginary = np.zeros((1,domain))
psi_present_real = np.zeros((1,domain))
psi_present_imaginary = np.zeros((1,domain))
psi_future_real = np.zeros((1,domain))
psi_future_imaginary = np.zeros((1,domain))
psi_probability = np.zeros(domain,) # Probability
xn = range(1,domain/2)
x = X[xn]/dx # Normalized position coordinate
gg = Gaussian(x,x0,sigma)
cx = np.cos(k0*x)
sx = np.sin(k0*x)
psi_present_real[xn] = cx*gg
psi_present_imaginary[xn] = sx*gg
psi_past_real[xn] = cx*gg
psi_past_imaginary[xn] = sx*gg
をつもりですガウス関数は
def Gaussian(x,t,sigma):
np.exp(-(x-t)**2/(2*sigma**2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Spyder 2.7.app/Contents/Resources/lib/python2.7/spyderlib/widgets/externalshell/sitecustomize.py", line 586, in runfile
execfile(filename, namespace)
File "/Users/kabirthakur/Desktop/untitled1.py", line 73, in <module>
psi_present_real[xn] = cx*gg
IndexError: index 1 is out of bounds for axis 0 with size 1
完全なトレースバックを提供してください。 –
へようこそ:[ツアー]に行って[MCVE]を読んでください。 –
@cᴏʟᴅsᴘᴇᴇᴅDone –