Created
October 23, 2015 03:40
-
-
Save tassoevan/944ca480ac00146d1d6b to your computer and use it in GitHub Desktop.
Esboço de um trabalho de Cálculo de Reatores
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Cálculo de Reatores Químicos</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> | |
</head> | |
<body class="asciimath2jax_ignore"> | |
<div class="container"> | |
<h1>Beber e não dirigir</h1> | |
<div id="output"></div> | |
</div> | |
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.0/jquery.scrollTo.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/jquery.flot.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> | |
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Config({ | |
showProcessingMessages: false, | |
tex2jax: { inlineMath: [['$','$'],['\\(','\\)']] }, | |
"HTML-CSS": { webFont: "Asana-Math" }, | |
TeX: { extensions: ["mhchem.js", "cancel.js"] } | |
}); | |
</script> | |
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script> | |
<script> | |
'use strict'; | |
var print, latex, asciimath, strong, plot; | |
$(function () { | |
var typesettingPool = $('<div>').css({ | |
position: 'absolute', | |
visibility: 'hidden' | |
}).addClass('asciimath2jax_process').appendTo('#output'); | |
function typeset(text, after) { | |
MathJax.Hub.Queue(function () { | |
typesettingPool.append(document.createTextNode(text)); | |
}); | |
MathJax.Hub.Queue(["Typeset", MathJax.Hub, typesettingPool.get(0)]); | |
MathJax.Hub.Queue(function () { | |
after(typesettingPool.contents().detach()); | |
}); | |
} | |
latex = function (code) { | |
return function (p) { | |
MathJax.Hub.Queue(function () { | |
typesettingPool.append(document.createTextNode('$' + code + '$')); | |
}); | |
MathJax.Hub.Queue(["Typeset", MathJax.Hub]); | |
MathJax.Hub.Queue(function () { | |
p.append(typesettingPool.contents().detach()); | |
}); | |
}; | |
}; | |
asciimath = function (code) { | |
return function (p) { | |
MathJax.Hub.Queue(function () { | |
typesettingPool.append(document.createTextNode('`' + code + '`')); | |
}); | |
MathJax.Hub.Queue(["Typeset", MathJax.Hub]); | |
MathJax.Hub.Queue(function () { | |
p.append(typesettingPool.contents().detach()); | |
}); | |
}; | |
}; | |
strong = function (text) { | |
return function (p) { | |
MathJax.Hub.Queue(function () { | |
$('<strong>').text(text).appendTo(p); | |
}); | |
}; | |
}; | |
print = function () { | |
if (print.ignorePrint) { | |
return; | |
} | |
var p = $('<p>').addClass('print'); | |
var getType = {}; | |
Array.prototype.slice.call(arguments).forEach(function (arg) { | |
if (arg && getType.toString.call(arg) === '[object Function]') { | |
arg(p); | |
} else { | |
MathJax.Hub.Queue(function () { | |
$('<span>').text(arg).appendTo(p); | |
}); | |
} | |
}); | |
MathJax.Hub.Queue(function () { | |
p.appendTo('#output'); | |
$('body').scrollTo('100%'); | |
}); | |
}; | |
print.ignorePrint = false; | |
plot = function (series, options) { | |
var plot = $('<div>').addClass('plot').appendTo('#output'); | |
plot.width('50%').height(plot.width() * 3 / 4); | |
$('body').scrollTo('100%'); | |
$.plot(plot, series, options); | |
return new (function (plot) { | |
var that = this; | |
that.update = function (series) { | |
$.plot(plot, series); | |
}; | |
})(plot); | |
}; | |
}); | |
</script> | |
<script src="programa.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
print.ignorePrint = false; | |
var sexo = "masculino"; | |
var idade = 25; | |
var massa = 125; | |
print(strong('Perfil da pessoa que irá beber')); | |
print('Sexo: ' + sexo); | |
print('Idade: ' + idade + ' anos'); | |
print('Massa: ' + massa + ' kg'); | |
print(strong('Variáveis descritas no problema')); | |
var x_fluido = 0; | |
if (idade <= 0.5) { | |
x_fluido = .74; | |
} else if (idade <= 1) { | |
x_fluido = .60; | |
} else if (idade <= 12) { | |
x_fluido = .60; | |
} else if (idade <= 18) { | |
x_fluido = sexo === "masculino" ? .59 : .56; | |
} else if (idade <= 50) { | |
x_fluido = sexo === "masculino" ? .59 : .50; | |
} else { | |
x_fluido = sexo === "masculino" ? .56 : .47; | |
} | |
print(latex('m = ' + massa + ' \\text{ kg}')); | |
print(latex('x_{fluido} = ' + x_fluido), ' (' + (x_fluido * 100).toFixed(0) + '%)'); | |
var rho_fluido = 1.1; | |
print(latex('\\rho_{fluido} = ' + rho_fluido + ' \\text{ kg}\\text{ L}^{-1}')); | |
var V_lata = 350 / 1000.0; | |
print(latex('V_{\\text{lata}} = ' + V_lata + ' \\text{ L}')); | |
var x_alcool = 0.047; | |
print(latex('x_{\\text{álcool}} = ' + x_alcool), ' (' + (x_alcool * 100).toFixed(1) + '%)'); | |
var rho_alcool = 0.789; | |
print(latex('\\rho_{\\text{álcool}} = ' + rho_alcool + ' \\text{ kg}\\text{ L}^{-1}')); | |
print(strong("Modelo proposto pelo problema")); | |
print(latex('$\\ce{Álcool -> Álcool\\ absorvido -> Produto}$')); | |
print(latex('$\\ce{A ->[k_\\text{absorção}] Ab ->[k_\\text{destruição}] P}$')); | |
print(latex('$(-r_{A}) = k_\\text{absorção} C_{A}$')); | |
print(latex('$(-r_{Ab}) = k_\\text{destruição}$')); | |
var k_absorcao = 10; | |
print(latex('k_\\text{absorção} = ' + k_absorcao + ' \\text{ h}^{-1}')); | |
var k_destruicao = 0.13; | |
print(latex('k_\\text{destruição} = ' + k_destruicao + ' \\text{ g} \\text{ L}^{-1} \\text{ h}^{-1}')); | |
print('Em ', latex('t = 0'), ','); | |
print(latex('$C_{A0} = \\frac{m_A}{V_\\text{fluido}}$')); | |
print(latex('$C_{Ab0} = \\frac{m_{Ab}}{V_\\text{fluido}}$')); | |
print(strong('Resolução do problema')); | |
var m_fluido = massa * x_fluido; | |
print(latex('$m_\\text{fluido} = m x_\\text{fluido} = ' + m_fluido + ' \\text{ kg}$')); | |
var V_fluido = m_fluido / rho_fluido; | |
print(latex('$V_\\text{fluido} = \\frac{m_\\text{fluido}}{\\rho_\\text{fluido}} = ' + V_fluido + ' \\text{ L}$')); | |
print(strong('a) '), 'Quanto tempo você deverá esperar para dirigir se beber duas latas de cerveja?'); | |
print('Concentrações iniciais:'); | |
var n_latas = 2; | |
print(latex('$n_\\text{latas} = ' + n_latas + '$')); | |
var m_A0 = n_latas * rho_alcool * V_lata; | |
print(latex('$m_A = n_\\text{latas} \\rho_{\\text{álcool}} V_{\\text{lata}} = ' + m_A0 + ' \\text{ kg}$')); | |
var C_A0 = m_A0 / V_fluido; | |
print(latex('$C_{A0} = \\frac{m_A}{V_\\text{fluido}} = ' + C_A0 + ' \\text{ kg}/ \\text{L}^{-1}$')); | |
var C_Ab0 = 0; | |
print(latex('$C_{Ab0} = ' + C_Ab0 + ' \\text{ kg}/ \\text{L}^{-1}$')); | |
var C_P0 = 0; | |
print(latex('$C_{P0} = ' + C_P0 + ' \\text{ kg}/ \\text{L}^{-1}$')); | |
print('Taxas de reação:'); | |
var r_A = function (C_A, C_Ab) { | |
return -k_absorcao * C_A; | |
}; | |
print(latex('$r_A = -k_\\text{absorção} C_A$')); | |
var r_Ab = function (C_A, C_Ab) { | |
return k_absorcao * C_A - (C_Ab > 0 ? k_destruicao : 0); | |
}; | |
print(latex('$r_{Ab} = k_\\text{absorção} C_A - k_\\text{destruição} {C_{Ab}}^0$')); | |
var r_P = function (C_A, C_Ab) { | |
return (C_Ab > 0 ? k_destruicao : 0); | |
}; | |
print(latex('$r_P = k_\\text{destruição} {C_{Ab}}^0$')); | |
print('Obs: ', latex('{C_{Ab}}^0 = 0'), ' quando ', latex('C_{Ab} = 0'), ', isto é, a função é descontínua apenas em ', latex('C_{Ab} = 0'), '.'); | |
print('Balanço material:'); | |
print('Não há gradiente de concentração de álcool no organismo ', latex('\\rightarrow'), ' tanque agitado'); | |
print('Não há taxa de entrada ou saída de componentes ', latex('\\rightarrow'), ' regime de batelada'); | |
print(latex('$\\frac{dm_i}{dt} = \\cancelto{0}{F_{i0}} - \\cancelto{0}{F_{i}} + \\cancelto{r_i\\int_{V_\\text{fluido}}{dV}}{\\int_{V_\\text{fluido}}{r_i dV}}$')); | |
print(latex('$\\frac{dm_i}{dt} = r_i V_\\text{fluido}$')); | |
print(latex( | |
'$\\frac{dm_i}{dt} = ' + | |
'\\frac{d}{dt}\\left[C_i V_\\text{fluido}\\right] = ' + | |
'C_i\\cancelto{0}{\\frac{dV_\\text{fluido}}{dt}} + V_\\text{fluido}\\frac{dC_i}{dt} = ' + | |
'V_\\text{fluido}\\frac{dC_i}{dt}$' | |
)); | |
print(latex('$\\cancel{V_\\text{fluido}}\\frac{dC_i}{dt} = r_i \\cancel{V_\\text{fluido}}$')); | |
print(latex('$\\frac{dC_i}{dt} = r_i$')); | |
print(latex('$dC_i = r_i dt$')); | |
print(latex('$\\int_{C_{i0}}^{C_i}{dC_{i}} = \\int_{0}^{t}{r_i dt}$')); | |
print(latex('$C_i - C_{i0} = \\int_{0}^{t}{r_i dt}$')); | |
print(latex('$C_i = C_{i0} + \\int_{0}^{t}{r_i dt}$')); | |
print(latex('$C_A = C_{A0} - k_\\text{absorção} \\int_{0}^{t}{C_A dt}$')); | |
print(latex('$C_{Ab} = C_{Ab0} + k_\\text{absorção} \\int_{0}^{t}{C_A dt} - k_\\text{destruição}\\int_{0}^{t}{{C_{Ab}}^0 dt}$')); | |
print(latex('$C_P = C_{P0} + k_\\text{destruição}\\int_{0}^{t}{{C_{Ab}}^0 dt}$')); | |
print('Resolução pelo método de Euler:'); | |
var dt = .0001; | |
print(latex('$dt \\approx \\Delta t = ' + dt + ' \\text{ h}$')); | |
print(latex('$t = k \\Delta t$')); | |
print(latex('$C_i(t) = C_i(k \\Delta t) \\approx {C_i}_k$')); | |
print(latex('$\\Delta {C_i}_k = {C_i}_{k + 1} - {C_i}_k = r_i \\Delta t$')); | |
print(latex('${C_i}_{k + 1} = {C_i}_k + \\Delta {C_i}_k$')); | |
print(latex('$\\Delta {C_A}_k = - k_\\text{absorção} {C_A}_k \\Delta t$')); | |
print(latex('$\\Delta {C_{Ab}}_k = k_\\text{absorção} {C_A}_k \\Delta t - k_\\text{destruição}{{C_{Ab}}_k}^0 \\Delta t$')); | |
print(latex('$\\Delta {C_P}_k = k_\\text{destruição}{{C_{Ab}}_k}^0 \\Delta t$')); | |
var C_Ak = C_A0; | |
var C_Abk = C_Ab0; | |
var C_Pk = C_P0; | |
print.ignorePrint = false; | |
var plotSeries = [ [[0, C_A0]], [[0, C_Ab0]], [[0, C_P0]] ]; | |
var plotConcentracoes = plot(plotSeries); | |
var k = 0; | |
dt = .001; | |
var f = function () { | |
C_Ak_1 = C_Ak + r_A(C_Ak, C_Abk) * dt; | |
C_Abk_1 = C_Abk + r_Ab(C_Ak, C_Abk) * dt; | |
C_Pk_1 = C_Pk + r_P(C_Ak, C_Abk) * dt; | |
++k; | |
plotSeries[0].push([k * dt, C_Ak_1]); | |
plotSeries[1].push([k * dt, C_Abk_1]); | |
plotSeries[2].push([k * dt, C_Pk_1]); | |
plotConcentracoes.update(plotSeries); | |
if (C_Ak_1 > 1e-9) { | |
C_Ak = C_Ak_1; | |
C_Abk = C_Abk_1; | |
C_Pk = C_Pk_1; | |
setTimeout(f, 100); | |
} | |
}; | |
f(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment