-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuler_rozamiento.py
143 lines (97 loc) · 2.77 KB
/
euler_rozamiento.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import os
import pandas as pd
NP = 103958
g = 9.81
L0 = (((0.1 / 10000) * (NP - 100000)) + 0.25) * 150
m = (40 / 10000) * (NP - 100000) + 50
k1 = (10 / 10000) * (NP - 100000) + 40
k2 = 0.66
c1 = (2 / 10000) * (NP - 100000) + 3
c2 = 1.5
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:
if vn >= 0:
vn1 = vn + h * (g - (k1 * (((un - L0) ** k2) / m)) - ((c1 * (abs(vn)) ** c2) / m))
else:
vn1 = vn + h * (g - (k1 * (((un - L0) ** k2) / m)) + ((c1 * (abs(vn)) ** c2) / m))
else:
if vn >= 0:
vn1 = vn + h * (g - ((c1 * (abs(vn)) ** c2) / m))
else:
vn1 = vn + h * (g + ((c1 * (abs(vn)) ** c2) / m))
return vn1
def w_n1(un, vn):
if un >= L0:
if vn >= 0:
wn1 = g - (k1 * (((un - L0) ** k2) / m)) - ((c1 * (abs(vn)) ** c2) / m)
else:
wn1 = g - (k1 * (((un - L0) ** k2) / m)) + ((c1 * (abs(vn)) ** c2) / m)
else:
if vn >= 0:
wn1 = g - ((c1 * (abs(vn)) ** c2) / m)
else:
wn1 = g + ((c1 * (abs(vn)) ** c2) / m)
return wn1
def main():
rows = [["N", "h", "un", "vn", "wn"]]
un = 0
vn = 0
wn = 0
h = 0.1
i = 1000
n = 0
limit = 150 * 0.9
cumple_1 = False
cumple_2 = True
cumple_3 = False
u_max = 0
a_max = 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, vn)
un = un1
vn = vn1
wn = wn1
rows.append([n, h, un, vn, wn])
if limit < un < 150:
cumple_1 = True
elif un > 150:
cumple_2 = False
if un > u_max:
u_max = un
a_max = wn
print("n:", n, "| un:", un, "| vn:", vn, "| wn:", wn)
if abs(a_max) <= (2.5 * g):
cumple_3 = True
if cumple_1 and cumple_2 and cumple_3:
print("Condiciones cumplidas! | k1:", k1, "| k2:", k2)
print("U MAX:", u_max)
print("A on MAX:", a_max)
else:
print("No cumple las condiciones | k1:", k1, "| k2:", k2)
print("U MAX:", u_max)
print("A on MAX:", a_max)
write_to_excel(rows)
main()