公式

  • emmm感觉这部分不需要公式啊 )
  • 默认为0,有四种情况,第三种用户的直接放弃,受迫和周期和0三种状态

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
def CalcPerturbation(self):
"""
Calculate the ambient water pressure perturbation.

Parameters:
x (float): Coordinate of the model nose related to the model length.
SwPert (int): Type of perturbation (1: Impulse, 2: Periodic, 3: User, 4: No perturbation).
Lm (float): Length of the model.
Timp (float): Time constant for impulse perturbation.
V0 (float): Initial velocity.
PmaxImp (float): Maximum pressure for impulse perturbation.
Head0 (float): Initial water head.
XpImp (float): Position of the impulse perturbation.
AmPer (float): Amplitude of the periodic perturbation.
ShPer (float): Spatial frequency of the periodic perturbation.
Xuser (list of float): User-defined positions for user perturbation.
Pw_User (list of float): User-defined pressures for user perturbation.
Np (int): Number of user-defined points for user perturbation.

Returns:
P1n (float): Calculated pressure perturbation.
"""
# 计算环境水压扰动
# def calc_perturbation(x, SwPert, Lm, Timp, V0, PmaxImp, Head0, XpImp, AmPer, ShPer, Xuser, Pw_User, Np):
# 扰动标识,默认为4没有压强扰动
SwPert = self.SwPert
# 脉冲扰动的时间常数,单位为ms
Timp = self.Timp
# 模型长度
Lm = self.Lm
# 模型初速度
V0 = self.V0
# 脉冲扰动的最大压力。
PmaxImp = self.PmaxImp
# 初始水头
Head0 = self.Head0
# 冲击扰动的中心位置?
XpImp = self.XpImp
# 当前无量纲位置
x = self.x
# 周期性扰动的振幅
AmPer = self.AmPer
# 周期性扰动的波数
ShPer = self.ShPer
# 用户定义的扰动
Xuser = self.Xuser
# 用户定义的扰动的点数
Np = self.Np
# 用户定义扰动的压力分布(数组,单位:MPa)
Pw_User = self.Pw_User

# Initialize pressure perturbation to zero
P1n = 0.0
# 强迫
# Impulse
if SwPert == 1:
St = 2.0 * np.pi * Lm * 1e3 / (Timp * V0)
Aka = PmaxImp * 1e6 / Head0
Xmp = XpImp / Lm
if x <= Xmp - np.pi / St or x >= Xmp + np.pi / St:
P1n = 0.0
else:
P1n = Aka * (1.0 + np.cos(St * (x - Xmp))) / 2.0
# Periodic
# 周期性
elif SwPert == 2:
P1n = AmPer * np.sin(ShPer * x)
# 用户定义,摒弃?
elif SwPert == 3: # User
if x < Xuser[0] / Lm or x > Xuser[Np - 1] / Lm:
P1n = 0.0
else:
# Interpolate user-defined pressure values
Xuser_norm = np.array(Xuser) / Lm
Pw_User_norm = np.array(Pw_User) * 1e6 / Head0
P1n = np.interp(x, Xuser_norm, Pw_User_norm)

elif SwPert == 4: # No perturbation
P1n = 0.0

self.P1n = P1n