
ich bin noch ein Anfänger, was Python angeht. Deshalb brauche ich eure Hilfe.
Ich wollte nur einen Eigenwert des Parameters h darstellen, aber mir wird folgende Fehlermeldung angezeigt
ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Ich habe auch schon das Internet durchforstet, aber bekomme das Problem nicht gelöst
import numpy as np
from scipy.spatial.transform import Rotation as R
import uncertainties.unumpy as unp
import matplotlib.pyplot as plt
import scipy.constants as const
#import pandas as pd
from scipy.stats import stats
from sklearn.preprocessing import normalize
from math import cos, sin, sqrt
from numpy import linalg
import cmath
from matplotlib.widgets import Slider, Button, RadioButtons
#Drehmatrix um Richtung (axis) um Winkel phi
def rotation(axis,phi,vec):
return (R.from_rotvec(np.radians(phi)*axis)).apply(vec)
zcrys=np.array([1,-1,0])
ycrys=np.array([1,1,0])
xcrys=np.array([0,0,1])
#Vektoren normieren
normalized_zcrys = zcrys/np.linalg.norm(zcrys)
normalized_ycrys = ycrys/np.linalg.norm(ycrys)
normalized_xcrys = xcrys/np.linalg.norm(xcrys)
k=normalized_zcrys
B=normalized_xcrys
#ε = 12.120 meV
ε=12100 #*10**(-22)*1.602
i=complex(0,1)
a=92.5
b=47.7
delta3=0
delta5=0
x=1/sqrt(2)
y=-1/sqrt(2)
z=0
B=normalized_xcrys
def H(h):
return ([ [-ε ,i*a*h*B[0],i*a*h*B[1],i*a*h*B[2]],
[-i*a*h*B[0],0,-i*b*h*B[2],i*b*h*B[1]],
[-i*a*h*B[1],i*b*h*B[2],0,-i*b*h*B[0]],
[-i*a*h*B[2],-i*b*h*B[1],i*b*h*B[0],0]]) #(4,4)
#H=H(h)
M1=delta3*np.matrix([[0,0,0,0],
[0,0,x*y,x*z],
[0,x*y,0,y*z],
[0,x*z,y*z,0]])
M2=delta5*np.matrix([[0,0,0,0],
[0,2*x*x-y*y-z*z,0,0],
[0,0,2*y*y-x*x-z*z,0],
[0,0,0,2*z*z-x*x-y*y]])
#M=H+M1+M2
def EW(h):
return (linalg.eig(H(h))[0])
#print(np.round(EW(0.1),3))
#print(EW(0.1).shape)
#print(np.round(EV[1],3))
xlist=np.linspace(0,10,10)
plt.plot(xlist,EW(xlist)[0],color='red')
plt.show()