【发布时间】:2021-04-12 07:00:25
【问题描述】:
我有一个方程,描述一个椭圆。我想使用 Python 来找到这些椭圆的最小和最大角度 theta 和轴 Lc 的长度,以便进一步计算。
参数 Lc1、theta1 等是各个角度的轴长度。
我尝试sympy.solve 没有成功(结果没有任何意义),现在正在尝试sympy.solveset。
这是我当前的脚本。接下来是需要theta的进一步计算。
import math
import sympy as sym
from sympy import solve, Eq
from sympy import *
import matplotlib.pyplot as plt
#define parameters
#Lc modelled with matlab before
Lc1 = 0.67 / 1000
Lc2 = 0.36/ 1000
Lc3 = 0.7 / 1000
#orientation of the cut section
theta1 = 89
theta2 = -35
theta3 = 25
#calculation from Beaudoin et al. (2016) and Ebner et al. (2010)
dL = ((Lc2 - Lc1)/(Lc3 - Lc1))
c = math.atan(- (((dL * (math.sin(2 * theta3) - math.sin(2 * theta1))) - (math.sin(2 * theta2) - math.sin(2* theta1)))/ ((dL * (math.cos(2 * theta3) - math.cos(2 * theta1))) - (math.cos(2 * theta2) - math.cos(2 * theta1)))))
b = ((Lc2 - Lc1)/((math.sin(2 * theta2 + c)) - (math.sin(2 * theta1 + c))))
a = Lc1 - (b * math.sin(2 * theta1 + c))
print('Done calculating a, b and c')
##try to find theta at min and max Lc
#theta = sym.symbols('theta')
theta = var('theta')
#define eqation that give us our crossover length
Lc = Eq(a + b * sym.sin(2 * theta +c))
dLc = Eq(2 * b * sym.cos(2 * theta +c) + sym.sin(2 * theta + c))
print('Busy finding minimum and maximum.')
sol = solveset(dLc, theta)
sol
#now we have the derivation we can go find min and max of Lc
使用solveset 到目前为止我没有收到任何结果,因为 python 不会停止运行。
我不确定是否可以使用当前脚本获得可靠的结果。怎么了?有没有更有效的方法?如果有人可以帮助我,我会很高兴!
提前谢谢!
【问题讨论】: