sparrow hat geschrieben: Mittwoch 5. Januar 2022, 07:32
Du musst schon das Programm zeigen, das den Fehler produziert - nicht irgend einen Code, der keine Probleme hat.
Und bitte die komplette Fehlermeldung inklusive vollständigem Stracktrace, damit man auch sieht, dass sympy den Fehler wirft. Zumindest vermute ich das.
Hier mal der wesentliche Auszug aus dem Programm, der Rest sind nur Tkinter Buttons und kleinere Berechnungen:
Code: Alles auswählen
import tkinter as tk
import numpy as np
import pandas as pd
import matplotlib as mtpl
import matplotlib.pyplot as plt
import csv
import sympy as sp
import sys
import time
import itertools
from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg,
NavigationToolbar2Tk)
from matplotlib.figure import Figure
from itertools import product
from sympy import *
from tkinter import Menu
from tkinter import *
from tkinter import ttk
from PIL import ImageTk, Image
from tkinter.filedialog import asksaveasfile
from tkinter.filedialog import askopenfilename
from tkinter import filedialog as fd
from tkinter.messagebox import showinfo
class HertzschePressung:
def CalculationPressureIB():
anzahl_scheiben = 50
effektive_länge = 11.52 #mm
krümmungsradius = 4.53 #mm
e_modul = 208000 #N/mm^2
einfederung = 0.003 #mm
profilierung = 0.00 #mm
shape = (1, anzahl_scheiben)
fillvalue_einfederung = einfederung
matrix_einfederung = np.full(shape, fillvalue_einfederung)
fillvalue_profilierung = profilierung
matrix_profilierung = np.full(shape, fillvalue_profilierung)
nachgiebigkeit = anzahl_scheiben * ((3.84 * 10 ** (-5)) / effektive_länge ** 0.8) ** (1 / 0.9)
länge_scheibe = (effektive_länge / anzahl_scheiben)
print('Länge Scheibe:', länge_scheibe, 'mm')
number = range(1, anzahl_scheiben+1, 1)
w = (4 / länge_scheibe)
print('Einfluss Scheibe aus sich selbst:', w, '1/mm')
result = []
for k, j in product(number, repeat=2):
if k == j:
result.append(w)
else:
w_kj = (1 / (abs((k - j)) * länge_scheibe))
result.append(w_kj)
liste_matrix = [result[x:x+anzahl_scheiben] for x in range(0, len(result), anzahl_scheiben)]
matrix = np.array(liste_matrix)
matrix_transponiert = np.transpose(matrix)
print(matrix_transponiert)
listSum = sum(result)
gewichtung = anzahl_scheiben/listSum
gewichtungsmatrix = gewichtung * matrix
gewichtungsmatrix_transponiert = gewichtung * matrix_transponiert
resultierende_einfederung = matrix_einfederung - matrix_profilierung
kontaktkraft = ((resultierende_einfederung) ** (1 / 0.9)) * (np.linalg.inv(gewichtungsmatrix_transponiert) * ((nachgiebigkeit * 0.5) ** (-1)))
print('Kontaktkraftmatrix:\n', kontaktkraft)
zeilen_summen = kontaktkraft.sum(axis=1)
lst = []
for x in zeilen_summen:
lst.append(x)
print('Scheibenkräfte:\n',lst)
hertz_pressung = np.sqrt((np.array(lst) * e_modul) / (8 * np.pi * krümmungsradius * länge_scheibe))
print('Hertz´sche Pressung:\n', hertz_pressung)
y_wert = hertz_pressung
plt.plot(y_wert)
plt.xlabel('Scheibenposition [mm]')
plt.ylabel('Flächenpressung [N/mm^2]')
plt.title('Pressungsberechnung')
plt.show()
ErgButton = tk.Button(self.lfErg, text="Berechnen", command=CalculationPressureIB(), bg="orange", width=16)
ErgButton.grid(row=5, column=6, padx=10, pady=2, sticky="e")
self.window.mainloop()
HertzschePressung()
Und das ist die Fehlermeldung:
Code: Alles auswählen
Traceback (most recent call last):
File "C:\Users\...\.spyder-py3\20211112_Theorie2_self.py", line 723, in <module>
HertzschePressung()
File "C:\Users\...\.spyder-py3\20211112_Theorie2_self.py", line 711, in __init__
ErgButton = tk.Button(self.lfErg, text="Berechnen", command=CalculationPressureIB(), bg="orange", width=16)
File "C:\Users\...\.spyder-py3\20211112_Theorie2_self.py", line 659, in CalculationPressureIB
for k, j in product(number, repeat=2):
File "C:\Users\...\lib\site-packages\sympy\concrete\products.py", line 605, in product
prod = Product(*args, **kwargs)
File "C:\Users\...\lib\site-packages\sympy\concrete\products.py", line 190, in __new__
obj = ExprWithIntLimits.__new__(cls, function, *symbols, **assumptions)
File "C:\Users\...\lib\site-packages\sympy\concrete\expr_with_limits.py", line 165, in __new__
pre = _common_new(cls, function, *symbols, **assumptions)
File "C:\Users\...\lib\site-packages\sympy\concrete\expr_with_limits.py", line 57, in _common_new
raise ValueError(
ValueError: specify dummy variables for Range(1, 51, 1)