mirror of
https://gitlab.com/MisterBiggs/aero-astro-calc.git
synced 2025-06-16 07:06:42 +00:00
added mohrs circle plotter
This commit is contained in:
parent
b4855eb735
commit
6460344bc5
@ -2,6 +2,7 @@ from math import sqrt
|
|||||||
|
|
||||||
from bokeh.models import Arrow
|
from bokeh.models import Arrow
|
||||||
from bokeh.plotting import figure, show
|
from bokeh.plotting import figure, show
|
||||||
|
from numpy import linspace, sin, cos, pi
|
||||||
|
|
||||||
from aero_astro_calc.dependencies.LatexLabel import LatexLabel
|
from aero_astro_calc.dependencies.LatexLabel import LatexLabel
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ class PlaneStress:
|
|||||||
LatexLabel(
|
LatexLabel(
|
||||||
x=-1.8,
|
x=-1.8,
|
||||||
y=1.8,
|
y=1.8,
|
||||||
text=f"\sigma_1 = {round(self.sigma_1,4)}",
|
text=f"\\sigma_1 = {round(self.sigma_1,4)}",
|
||||||
render_mode="css",
|
render_mode="css",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -71,7 +72,7 @@ class PlaneStress:
|
|||||||
LatexLabel(
|
LatexLabel(
|
||||||
x=-1.8,
|
x=-1.8,
|
||||||
y=1.4,
|
y=1.4,
|
||||||
text=f"\sigma_2 = {round(self.sigma_2,4)}",
|
text=f"\\sigma_2 = {round(self.sigma_2,4)}",
|
||||||
render_mode="css",
|
render_mode="css",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -85,3 +86,74 @@ class PlaneStress:
|
|||||||
)
|
)
|
||||||
|
|
||||||
show(plot)
|
show(plot)
|
||||||
|
|
||||||
|
def mohr(self):
|
||||||
|
padding = 1.3
|
||||||
|
midpoint = (self.sigma_1 + self.sigma_2) / 2
|
||||||
|
|
||||||
|
plot = figure(
|
||||||
|
x_range=[
|
||||||
|
(midpoint - self.tau_max) * padding,
|
||||||
|
(midpoint + self.tau_max) * padding,
|
||||||
|
],
|
||||||
|
y_range=[-self.tau_max * padding, self.tau_max * padding],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Bokeh circle is stupid so it has to be done the hard way.
|
||||||
|
theta = linspace(0, 2 * pi, 200)
|
||||||
|
sig1 = self.tau_max * cos(theta) + midpoint
|
||||||
|
sig2 = self.tau_max * sin(theta)
|
||||||
|
plot.line(x=sig1, y=sig2)
|
||||||
|
|
||||||
|
# x axis
|
||||||
|
plot.line(
|
||||||
|
x=[
|
||||||
|
(midpoint - self.tau_max) * padding,
|
||||||
|
(midpoint + self.tau_max) * padding,
|
||||||
|
],
|
||||||
|
y=[0, 0],
|
||||||
|
line_color="black",
|
||||||
|
)
|
||||||
|
|
||||||
|
# y axis
|
||||||
|
plot.line(
|
||||||
|
x=[0, 0],
|
||||||
|
y=[self.tau_max * padding, self.tau_max * -padding],
|
||||||
|
line_color="black",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Labels
|
||||||
|
# sigma_1
|
||||||
|
plot.circle(x=midpoint + self.tau_max, y=0, size=self.tau_max * 0.2)
|
||||||
|
plot.add_layout(
|
||||||
|
LatexLabel(
|
||||||
|
x=midpoint + self.tau_max,
|
||||||
|
y=self.tau_max * -0.1,
|
||||||
|
text=f"\\sigma_1 = {round(self.sigma_1)}",
|
||||||
|
render_mode="css",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# sigma_2
|
||||||
|
plot.circle(x=midpoint - self.tau_max, y=0, size=self.tau_max * 0.2)
|
||||||
|
plot.add_layout(
|
||||||
|
LatexLabel(
|
||||||
|
x=midpoint - self.tau_max,
|
||||||
|
y=self.tau_max * -0.1,
|
||||||
|
text=f"\\sigma_2 = {round(self.sigma_2)}",
|
||||||
|
render_mode="css",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# tau_max
|
||||||
|
plot.circle(x=midpoint, y=self.tau_max, size=sqrt(self.tau_max))
|
||||||
|
plot.add_layout(
|
||||||
|
LatexLabel(
|
||||||
|
x=midpoint,
|
||||||
|
y=self.tau_max * 0.9,
|
||||||
|
text=f"\\tau_{{max}} = {round(self.tau_max)}",
|
||||||
|
render_mode="css",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
show(plot)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user