mirror of
https://gitlab.com/MisterBiggs/aero-astro-calc.git
synced 2025-06-15 22:56:47 +00:00
Merge branch 'mohrs-circle' into 'master'
Mohrs circle See merge request MisterBiggs/aero-astro-calc!4
This commit is contained in:
commit
e201b231ef
@ -2,7 +2,6 @@ stages:
|
|||||||
- deploy
|
- deploy
|
||||||
- test
|
- test
|
||||||
|
|
||||||
|
|
||||||
black:
|
black:
|
||||||
stage: test
|
stage: test
|
||||||
image: python:3.8
|
image: python:3.8
|
||||||
@ -14,19 +13,12 @@ black:
|
|||||||
script:
|
script:
|
||||||
- black --check .
|
- black --check .
|
||||||
|
|
||||||
|
pypi:
|
||||||
# https://github.com/python-gitlab/python-gitlab/blob/master/.gitlab-ci.yml used for reference
|
|
||||||
deploy:
|
|
||||||
stage: deploy
|
|
||||||
image: python:3.8
|
image: python:3.8
|
||||||
|
stage: deploy
|
||||||
before_script:
|
|
||||||
- python -V # Print out python version for debugging
|
|
||||||
- pip install -U setuptools wheel twine
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- python setup.py bdist_wheel
|
- apt-get update -qy
|
||||||
- twine upload --skip-existing -u __token__ -p $PYPI_TOKEN dist dist/*
|
- apt-get install -y ruby-dev
|
||||||
|
- gem install dpl
|
||||||
only:
|
- python setup.py sdist
|
||||||
- tags
|
- dpl --provider=pypi --user=$TWINE_USERNAME --password=$TWINE_PASSWORD --skip_existing=true
|
||||||
|
35
README.md
35
README.md
@ -2,17 +2,44 @@
|
|||||||
|
|
||||||
A small python library with functions to assist engineers.
|
A small python library with functions to assist engineers.
|
||||||
|
|
||||||
## Usage
|
## Getting Started
|
||||||
|
|
||||||
### Code:
|
- Install using pip:
|
||||||
|
|
||||||
|
```
|
||||||
|
pip install aero-astro-calc
|
||||||
|
```
|
||||||
|
|
||||||
|
- Import into your Python project
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from aero_astro_calc import PlaneStress
|
from aero_astro_calc import PlaneStress
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Make plane stress object:
|
||||||
|
|
||||||
|
```python
|
||||||
stress = PlaneStress(80, -40, 25)
|
stress = PlaneStress(80, -40, 25)
|
||||||
|
```
|
||||||
|
|
||||||
|
View the stress on a 2D plane:
|
||||||
|
|
||||||
|
```python
|
||||||
stress.plane()
|
stress.plane()
|
||||||
```
|
```
|
||||||
|
|
||||||
### Output:
|

|
||||||
|
|
||||||

|
View Mohr's circle of the stresses:
|
||||||
|
|
||||||
|
```python
|
||||||
|
stress.mohr()
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Contact
|
||||||
|
|
||||||
|
Anson Biggs - [anson@ansonbiggs.com](mailto:anson@ansonbiggs.com) - [@Anson_3D](https://twitter.com/Anson_3D)
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
from math import sqrt
|
from aero_astro_calc.dependencies.LatexLabel import LatexLabel
|
||||||
|
|
||||||
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 cos, linspace, pi, sin, sqrt
|
||||||
from aero_astro_calc.dependencies.LatexLabel import LatexLabel
|
|
||||||
|
|
||||||
|
|
||||||
class PlaneStress:
|
class PlaneStress:
|
||||||
@ -63,7 +61,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 +69,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 +83,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)
|
||||||
|
BIN
images/MohrsCircle.png
Normal file
BIN
images/MohrsCircle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="aero_astro_calc",
|
name="aero_astro_calc",
|
||||||
version="2020.1.0",
|
version="2020.2.0",
|
||||||
author="Anson Biggs",
|
author="Anson Biggs",
|
||||||
author_email="anson@ansonbiggs.com",
|
author_email="anson@ansonbiggs.com",
|
||||||
description="A small python library with functions to assist engineers.",
|
description="A small python library with functions to assist engineers.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user