-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuler.py
101 lines (68 loc) · 1.65 KB
/
euler.py
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import os
import pandas as pd
NP = 103958
g = 9.81
L0 = 43.437
m = 65.832
k1 = 43.958
#L0 = (((0.1/10000) * (NP - 100000)) + 0.25) * 150
#m = (40/10000) * (NP - 100000) + 50
#k1 = (10/10000) * (NP - 100000) + 40
def write_to_excel(rows):
new_sheet = {}
for i in range(len(rows[0])):
column_name = rows[0][i]
data = []
for row in rows:
data.append(row[i])
new_sheet[column_name] = data
new_df = pd.DataFrame(new_sheet)
new_df = new_df.iloc[1:, :]
filename = 'datos.xlsx'
filePath = os.path.join(filename, filename)
writer = pd.ExcelWriter(filePath, engine='xlsxwriter')
new_df.to_excel(writer)
writer.save()
def u_n1(un, vn, h):
un1 = un + (h * vn)
return un1
def v_n1(un, vn, h):
if un >= L0:
vn1 = vn + (h * (g - ((k1 * (un - L0))/m)))
else:
vn1 = vn + (h * g)
return vn1
def w_n1(un):
if un >= L0:
wn1 = (g - ((k1 * (un - L0))/m))
else:
wn1 = g
return wn1
def main():
rows = [["N", "h", "un", "vn", "wn"]]
un = 0
vn = 0
wn = 0
h = 0.1
i = 1000
n = 0
y_lim = 0
a_lim = 0
rows.append([n, h, un, vn, wn])
print("n:", n, "| un:", un, "| vn:", vn, "| wn:", wn)
while n < i:
n += 1
un1 = u_n1(un, vn, h)
vn1 = v_n1(un1, vn, h)
wn1 = w_n1(un)
un = un1
vn = vn1
wn = wn1
if un > y_lim:
y_lim = un
a_lim = wn
rows.append([n, h, un, vn, wn])
print("n:", n, "| un:", un, "| vn:", vn, "| wn:", wn)
print("Y lim:", y_lim, "| A lim:", a_lim)
write_to_excel(rows)
main()