Skip to content

Commit

Permalink
Vertaling HYMTR code
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuiderwi committed Sep 20, 2024
1 parent 5e22238 commit d71396f
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 56 deletions.
52 changes: 44 additions & 8 deletions src/lockgate/lockgate5/HYMS.py
Original file line number Diff line number Diff line change
@@ -1,75 +1,100 @@
import numpy as np

# Subroutine VOL Functie
def VOL(h1, w1, w2, uo, dl, p, q, alfa):
phi = np.zeros(101)
for x in range(1, h1 + 1):
phi[x] = -p[x, w1 + 1] + p[x, w1 + w2 + 1] + 0.5 * q[x]
alfa[x] = phi[x] / uo

V = 0.0
for x in range(1, h1 + 1):
V += alfa[x] * dl

return V, alfa

# VELD subroutine
def VELD(x, z, rl, p):
po = p[x, z]
pr = (p[x-1, z] + p[x, z+1] + p[x+1, z] + p[x, z-1]) / 4
p[x, z] = po + rl * (pr - po)

# PHI-RANDEN subroutines
# PHI-RANDEN subroutines --> Deze rand is niet in beweging (grenst aan water of aan lucht)
#bovenrand, phi=0
def P1(x, z, rl, p):
po = p[x, z]
pr = (p[x-1, z] + p[x, z-1] + p[x+1, z]) / 5
p[x, z] = po + rl * (pr - po)

#linkerrand, phi=0
def P2(x, z, rl, p):
po = p[x, z]
pr = (p[x, z+1] + p[x+1, z] + p[x, z-1]) / 5
p[x, z] = po + rl * (pr - po)

#benedenrand, phi=0
def P3(x, z, rl, p):
po = p[x, z]
pr = (p[x-1, z] + p[x, z+1] + p[x+1, z]) / 5
p[x, z] = po + rl * (pr - po)

#rechterrand, phi=0
def P4(x, z, rl, p):
po = p[x, z]
pr = (p[x, z+1] + p[x-1, z] + p[x, z-1]) / 5
p[x, z] = po + rl * (pr - po)

# VN-RANDEN subroutines
# VN-RANDEN subroutines (Vaste randvoorwaarde, bodem of de kant van de sluis. Hier is dus geen debiet (q) mogelijk!)
#bovenrand, vn=0
def V1(x, z, rl, p):
po = p[x, z]
pr = (p[x-1, z] + p[x, z-1] + p[x+1, z]) / 3
p[x, z] = po + rl * (pr - po)

#linkerrand, vn=0
def V2(x, z, rl, p):
po = p[x, z]
pr = (p[x, z+1] + p[x+1, z] + p[x, z-1]) / 3
p[x, z] = po + rl * (pr - po)

#benedenrand, vn=0
def V3(x, z, rl, p):
po = p[x, z]
pr = (p[x-1, z] + p[x, z+1] + p[x+1, z]) / 3
p[x, z] = po + rl * (pr - po)

#rechterrand, vn=0
def V4(x, z, rl, p):
po = p[x, z]
pr = (p[x, z+1] + p[x-1, z] + p[x, z-1]) / 3
p[x, z] = po + rl * (pr - po)

# Q-RANDEN subroutines
# Q-RANDEN subroutines (grenzend aan de sluisdeur --> Q betekent er is beweging aan deze rand, gezien water in rust is, is de enige vorm van beweging afkomstig van de vibrerende deur)
#bovenrand, qschuif
def Q1(x, z, rl, p, q):
po = p[x, z]
pr = (-q[x] + p[x-1, z] + p[x, z-1] + p[x+1, z]) / 3
p[x, z] = po + rl * (pr - po)

#bovenrand, qschuif
def Q2(x, z, rl, p, q):
po = p[x, z]
pr = (q[z] + p[x, z+1] + p[x+1, z] + p[x, z-1]) / 3
p[x, z] = po + rl * (pr - po)

#benedenrand, qschuif
def Q3(x, z, rl, p, q):
po = p[x, z]
pr = (q[x] + p[x-1, z] + p[x, z+1] + p[x+1, z]) / 3
p[x, z] = po + rl * (pr - po)

#rechterrand, qschuif
def Q4(x, z, rl, p, q):
po = p[x, z]
pr = (-q[z] + p[x, z+1] + p[x-1, z] + p[x, z-1]) / 3
p[x, z] = po + rl * (pr - po)

# PHI/PHI-HOEKEN subroutines
# PHI/PHI-HOEKEN subroutines (hoeken die grenzen aan twee water/lucht randen)
def PP5(x, z, rl, p):
po = p[x, z]
pr = (p[x+1, z] + p[x, z-1]) / 6
Expand All @@ -90,7 +115,7 @@ def PP8(x, z, rl, p):
pr = (p[x-1, z] + p[x, z-1]) / 6
p[x, z] = po + rl * (pr - po)

# VN/VN-HOEKEN subroutines
# VN/VN-HOEKEN subroutines (hoeken die aan twee kanten een muur hebben, geen debieten dus)
def VV5(x, z, rl, p):
po = p[x, z]
pr = (p[x+1, z] + p[x, z-1]) / 2
Expand All @@ -111,7 +136,7 @@ def VV8(x, z, rl, p):
pr = (p[x-1, z] + p[x, z-1]) / 2
p[x, z] = po + rl * (pr - po)

# PHI/VN-HOEKEN Subroutines
# PHI/VN-HOEKEN Subroutines (Hoek met een rand water/lucht en andere rand een muur)
def PV5(x, z, rl, p):
po = p[x, z]
pr = (p[x+1, z] + p[x, z-1]) / 4
Expand All @@ -132,48 +157,58 @@ def PV8(x, z, rl, p):
pr = (p[x-1, z] + p[x, z-1]) / 4
p[x, z] = po + rl * (pr - po)

# Q/PHI-HOEKEN Subroutines
# Q/PHI-HOEKEN Subroutines (Hoek met een rand sluisdeur die vibreert en andere kant water/lucht)
def QP5(x, z, rl, p, q):
#linkerbovenhoek, links q en boven phi=0
po = p[x, z]
pr = (q[z] + p[x+1, z] + p[x, z-1]) / 4
p[x, z] = po + rl * (pr - po)

def QP6(x, z, rl, p, q):
#linkeronderhoek, links q en onder phi=0
po = p[x, z]
pr = (q[z] + p[x+1, z] + p[x, z+1]) / 4
p[x, z] = po + rl * (pr - po)

def QP7(x, z, rl, p, q):
#rechteronderhoek, rechts q en onder phi=0

po = p[x, z]
pr = (-q[z] + p[x-1, z] + p[x, z+1]) / 4
p[x, z] = po + rl * (pr - po)

def QP8(x, z, rl, p, q):
#rechterbovenhoek, rechts q en onder phi=0
po = p[x, z]
pr = (-q[z] + p[x-1, z] + p[x, z-1]) / 4
p[x, z] = po + rl * (pr - po)

# PHI/Q-HOEKEN Subroutines
# PHI/Q-HOEKEN Subroutines (Hoeken met een kant water/lucht, andere kant de sluisdeur)
def PQ5(x, z, rl, p, q):
#Linkerbovenhoek, boven q en links phi=0
po = p[x, z]
pr = (-q[x] + p[x+1, z] + p[x, z-1]) / 4
p[x, z] = po + rl * (pr - po)

def PQ6(x, z, rl, p, q):
#Linkeronderhoek, onder q en links phi=0
po = p[x, z]
pr = (-q[x] + p[x+1, z] + p[x, z+1]) / 4
p[x, z] = po + rl * (pr - po)

def PQ7(x, z, rl, p, q):
#rechteronderhoek, onder q en recht phi=0
po = p[x, z]
pr = (q[x] + p[x-1, z] + p[x, z+1]) / 4
p[x, z] = po + rl * (pr - po)

def PQ8(x, z, rl, p, q):
#Rechterbovenhoek, boven q en rechts phi=0
po = p[x, z]
pr = (q[x] + p[x-1, z] + p[x, z-1]) / 4
p[x, z] = po + rl * (pr - po)

#Q_VN-HOEKEN (Hoeken met een kant sluisdeur en andere rand een muur zonder debiet)
def QV5(x, z, rl, p, q):
# linker bovenhoek, links q en boven vn=0
po = p[x][z]
Expand All @@ -198,6 +233,7 @@ def QV8(x, z, rl, p, q):
pr = (-q[z] + p[x-1][z] + p[x][z-1]) / 2
p[x][z] = po + rl * (pr - po)

#VN/Q-HOEKEN (HOeken met een kant een muur en andere kant een sluisdeur)
def VQ5(x, z, rl, p, q):
# linker bovenhoek, boven q en links vn=0
po = p[x][z]
Expand Down
Loading

0 comments on commit d71396f

Please sign in to comment.