非共點力系平衡的條件是:主矢和主矩都為0。這裡討論的是平面力系,空間力系原理相同。
**參考:
in_static_equilibrium.py
"""
checks if a system of forces is in static equilibrium.
#檢測力系是否平衡
python/black : true
flake8 : passed
mypy : passed
"""from typing import list
from numpy import array, cos, cross, radians, sin # type: ignore
defpolar_force
( magnitude:
float
, angle:
float
, radian_mode:
bool
=false)-
> list[
float]:
""" resolves force along rectangular components.
#將力投射到x、y軸
(force, angle) => (force_x, force_y)
>>> polar_force(10, 45)
[7.0710678118654755, 7.071067811865475]
>>> polar_force(10, 3.14, radian_mode=true)
[-9.999987317275394, 0.01592652916486828]
"""#numpy.cos引數要求弧度
if radian_mode:
return
[magnitude * cos(angle)
, magnitude * sin(angle)
]#如果是角度,需要用radians函式轉化為弧度
return
[magnitude * cos(radians(angle)
), magnitude * sin(radians(angle))]
#forces:力,location:點
defin_static_equilibrium
( forces: array, location: array, eps:
float=10
**-1)
->
bool
:#精確度0.1
#計算主矢,原**中並未考慮這一項,不明所以
vector =
sum(
list
(map
(abs
,sum
(forces)))
)# summation of moments is zero
#計算主矩,因為是平面力系,所以返回的是標量陣列
moments: array = cross(location, forces)
sum_moments:
float
=sum
(moments)
force_balance=
(abs
(vector)
<
10**-1
)
moment_balance=\
(abs(sum_moments)
<
10**-1
)print
(forces)
print
(location)
print
('該力系主矢{}平衡!'
.format(''
if force_balance else
'不')
)print
('該力系主矩{}平衡!'
.format(''
if moment_balance else
'不')
)return force_balance and moment_balance
if __name__ ==
"__main__"
:# test to check if it works
forces = array(
[polar_force(
718.4
,180-30
), polar_force(
879.54,45
), polar_force(
100,-90
)]) location = array([[
0,0]
,[0,
0],[
0,0]
])in_static_equilibrium(forces, location)
forces = array(
[ polar_force(30*
9.81,15
),polar_force(
215,
180-45)
, polar_force(
264,90-
30),]
) location = array([[
0,0]
,[0,
0],[
0,0]
])in_static_equilibrium(forces, location)
forces = array([[
0,-2000],
[0,-
1200],
[0,15600],
[0,-
12400]]
) location = array([[
0,0]
,[6,
0],[
10,0]
,[12,
0]])
in_static_equilibrium(forces, location)
import doctest
doctest.testmod(verbose=
true
)
小型網際網路業務環境的搭建(非雲平)
現在越來越多企業已經搭建自己的 或者已經部署了網際網路業務。隨著雲環境大火,更多人業務已經部署上雲,但是某些場景仍需要在內部部署一套業務環境並提供外網服務。本文簡單描述了乙個非雲平台網際網路業務環境的搭建,環境規模較小 普通業務,非流服務 規劃對外提供http https服務。拓撲圖如下,搭建環境用...