## 引言
我一直认为没有必要在考试中求截面矩和质心一类玩意，因为现在的电脑太容易求出这些几何性质的量了。Ansys和AutoCAD都内置了相关函数，其实就算要求解析解也不困难，这里就做个演示。


```python
%pylab inline
from sympy import Polygon, Point, var, init_printing, simplify, series
import sympy
init_printing()
var('b,h,t')
from second_moments import second_moments
```

    Populating the interactive namespace from numpy and matplotlib


## 矩形截面：
假设宽为b，高为h。


```python
p = map(Point,((0,0),(b,0),(b,h),(0,h)))
poly = Polygon(*p)
poly.area
```


```python
poly.centroid
```


```python
Ix, Iy, Ixy = second_moments(poly)
Ix, Iy, Ixy
```

## L形截面
假设厚度都是t,宽为b，高为h


```python
p = map(Point,((0,0),(b,0),(b,t),(t,t),(t,h),(0,h)))
poly = Polygon(*p)
poly.area
```


```python
simplify(poly.centroid)
```


```python
Ix, Iy, Ixy = simplify(second_moments(poly))
Ix, Iy, Ixy
```

你实际上还可以得到$t$是小量时候的二阶近似


```python
simplify(sympy.series(Ix,t,n=2).removeO())
```


```python
simplify(sympy.series(Iy,t,n=2).removeO())
```


```python
simplify(sympy.series(Ixy,t,n=2).removeO())
```

## 六边形：
外接圆半径为R的吧！


```python
var('R')
p = [(sympy.cos(i)*R,sympy.sin(i)*R) for i in arange(6)/sympy.S.One/3*sympy.pi]
poly = Polygon(*p)
p
```


```python
poly.area
```


```python
poly.centroid
```


```python
second_moments(poly)
```

## 工字梁
等厚为$t$的情况。


```python
p = map(Point,((0,0),(b,0),(b,t),(b/2+t/2,t),(b/2+t/2,h-t),
(b,h-t),(b,h),(0,h),(0,h-t),(b/2-t/2,h-t),(b/2-t/2,t),(0,t))
)
poly = Polygon(*p)
poly.area,poly.centroid
```


```python
I = second_moments(poly)
Ix,Iy,Ixy=map(simplify,I)
Ix, Iy, Ixy
```


```python
series(Ix,t,0,2), series(Iy,t,0,2), series(Ixy,t,0,2)
```

翼缘和肋板不等厚的情况，翼缘为$t1$，肋板为$t2$的情况。


```python
var('t1,t2')
p = map(Point,((0,0),(b,0),(b,t1),(b/2+t2/2,t1),(b/2+t2/2,h-t1),
(b,h-t1),(b,h),(0,h),(0,h-t1),(b/2-t2/2,h-t1),(b/2-t2/2,t1),(0,t1))
)
poly = Polygon(*p)
poly.area,poly.centroid
```


```python
I = second_moments(poly)
Ix,Iy,Ixy=map(simplify,I)
Ix, Iy, Ixy
```


```python
series(series(series(Ix,t1,n=2),t2,n=2).removeO().expand(),t1*t2,n=1).removeO()
```


```python
series(series(series(Iy,t1,n=2),t2,n=2).removeO().expand(),t1*t2,n=1).removeO()
```


```python
series(series(series(Ixy,t1,n=2),t2,n=2).removeO().expand(),t1*t2,n=1).removeO()
```

## 槽钢的情况
等厚为$t$


```python
p = map(Point,((0,0),(b,0),(b,t),(t,t),(t,h-t),
(b,h-t),(b,h),(0,h)))
poly = Polygon(*p)
poly.area,poly.centroid
```


```python
I = second_moments(poly)
Ix,Iy,Ixy=map(simplify,I)
Ix, Iy, Ixy
```


```python
simplify(series(Ix,t,0,2).removeO()), simplify(series(Iy,t,0,2).removeO()), series(Ixy,t,0,2)
```


```python

```

ae3161db39cb907096109530f0b23d17031df2c8
ipynb
Jupyter Notebook
public/other/second_moments_demo.ipynb
wanglongqi/wanglongqi.github.io
359f16930d4b0af8b377657d9bade7fd64120027
MIT
2015-02-11T02:09:18.000Z
2021-03-30T03:07:53.000Z
public/other/second_moments_demo.ipynb
wanglongqi/wanglongqi.github.io
359f16930d4b0af8b377657d9bade7fd64120027
MIT
public/other/second_moments_demo.ipynb
wanglongqi/wanglongqi.github.io
359f16930d4b0af8b377657d9bade7fd64120027
MIT
2015-01-24T14:17:48.000Z
2022-02-11T16:54:13.000Z
Qwen/Qwen-72B
1. YES
2. YES