-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.html
133 lines (121 loc) · 4.77 KB
/
main.html
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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="author" content="Rodrigo Iván Avila Demitroff">
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0">-->
<title>
Operaciones Unitarias I
</title>
<style>
/*#wob {
color: white;
background-color: black;
}*/
body {
color: black;
background-color: eggshell;
}
/*#tablebow{
border: 1px solid black;
border-collapse: collapse;
}
#tablewob{
border: 1px solid white;
border-collapse: collapse;
}
th{
border: 1px solid black;
border-collapse: collapse;
}*/
footer{
position: fixed;
bottom: 10px;
}
input{
padding:5px;
}
</style>
</head>
<body>
<h2>Diámetro mínimo según pérdida máxima</h2>
<!--<form>
<input type="radio" name="contraste" value="true" checked onclick="contrast(true)">Alto contraste<br>
<input type="radio" name="contraste" values="false" onclick="contrast(false)">Normal<br>
</form>-->
<p>Este documento contiene un pequeño programa en JavaScript.<br>
Acepta notación científica. Ejemplo 2.3e-2 = 0.023</p>
<fieldset <!--style="width:45%"-->
<legend><strong>Datos</strong></legend>
<table>
<tr><td>Caudal [m³/s]</td><td><input type="number" id="caudal" autofocus></td></tr>
<tr><td>Longitud [m]</td><td><input type="number" id="longitud" placeholder="L+Leq"></td></tr>
<tr><td>Pérdida máxima de cabeza [m]</td><td><input type="number" id="headLoss"></td></tr>
<tr><td>Viscosidad dinámica [kg/m·s]</td><td><input type="number" id="visc"></td></tr>
<tr><td>Densidad [kg/m³]</td><td><input type="number" id="densidad" value="998"></td></tr>
<tr><td>Rugosidad absoluta [m]</td><td><input type="number" id="rugosidad"></td></tr>
</table>
</fieldset>
<button onclick="pipes()" id="submit">Submit</button><span class= "toErase" id="appear"></span>
<p><div>Diámetro<span class="toErase ith"></span>: <span class= "toErase" id="diametroRes"></span>  m</div>
<div>Reynolds<span class="toErase ith"></span>: <span class= "toErase" id="reyRes"></span></div>
<div>Rugosidad relativa<span class="toErase ith"></span>: <span class= "toErase" id="rugRelRes"></span></div></p>
<button onclick="clean()" style="background-color:red; border-radius:5px"><strong>Clean</strong></button>
<footer>
<small>© 2018 Rodrigo Iván Avila Demitroff.</small>
<footer>
<script>
/*MIT License
Copyright (c) 2018 Rodrigo Ivan Avila Demitroff
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var beenHere = 0;
var f_i = 0.04;
var ith = 0;
function pipes(){
var caudal = document.getElementById("caudal").value;
var longitud = document.getElementById("longitud").value;
var headLoss = document.getElementById("headLoss").value;
var viscosidad = document.getElementById("visc").value;
var densidad = document.getElementById("densidad").value;
var rugosidad = document.getElementById("rugosidad").value;
var a = 0.0;
var reConst = 0.0;
var g = 9.81;
a = 8 * caudal**2 * longitud / (headLoss * g * Math.pow(Math.PI, 2));
reConst = 4 * caudal / (Math.PI * (viscosidad/densidad));
if (0 == beenHere) {document.getElementById("appear").innerHTML = "<input type='number' id='endgame'>";}
else {f_i = document.getElementById("endgame").value;}
beenHere = 1;
var x = document.getElementsByClassName("ith");
for (var i = 0; i<x.length; i++) {x[i].innerHTML = ith;}
ith++;
document.getElementById("diametroRes").innerHTML = Math.pow((a*f_i),(1/5));
document.getElementById("rugRelRes").innerHTML = rugosidad/((a*f_i)**(1/5));
document.getElementById("reyRes").innerHTML = reConst/Math.pow(a*f_i,1/5);
}
function clean(){
document.getElementById("appear").innerHTML = "";
beenHere = 0;
f_i = 0.04;
ith = 0;
var x= document.getElementsByClassName("toErase");
for (var i = 0; i < x.length; i++) {x[i].innerHTML= ""}
}
</script>
</body>
</html>