Übung: online "Stirling 4You" in Javascript
Erscheinungsbild
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:myad><HEAD><TITLE>Stirling engine analysis</TITLE>
<!meta http-equiv="refresh" content="3; URL=4You_ef--.hta">
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<!Please do not trust these values given thru this program (i'm just an interrested amateur) - You have to proof it by yourself - maybe You can use the structure of this program for Your own calculating code>
<! Thanks to Alan Altman for his description of his comprehensive stirling analysis tool, which inspired me, too. Highly recommended: http://snapburner.home.comcast.net/index.html>
<! Thanks to Koichi Hirata for his theory of stirling analysis for alpha, beta and gamma engines>
<! Thanks to Lutz Tautenhahn, who gave me an idea how to create a diagram in html-files>
<! Thanks to Sesusa (Yahoogroup), who helped me to solve some of my understanding problems easier and faster>
<! Thanks to Mr. Urieli, whose internet pages with information improved my knowledge about stirling engine analysis>
<! Thanks to all people, who inspired my thinking - hopefully for a better and environfriendly world for all of us>
<! to do >
<! diagram - improvement: scales and cleaning source code, Html5 canvas?>
<! clear visible structure: input, calculation, output>
<! .hta and .htm "compatibility": usage of clipboard (ie?), instead of saving values into files, printing array values into document(.open()), forward and back button? possible?)>
<! change between inch and metric system should change values too! (calculating with Si-units and their derivatives)>
<! testing on netscape and opera browsers and linux system>
<! gradient following optimisation (GRG, SQP, Newton/Raphson, etc.)? >
<! maximum energy output - testing of all possibilities>
<! alpha, beta, gamma hirata (sinusoidal, ross yoke) formulas for adiabatic, simple analysis
<! Manson, LaminaFlow?>
<! Zig Herzogs analysis theory - comparing outputs>
<style type="text/css">
Font {font-size:10}
DIV {color:black; font-size:12px; width:250px}
Label {color:gray; font-size:10; font-stretch:wider; letter-spacing:0.1pt; line-height:12pt; height:10px; width:150px}
.check_class {width:60px}
.radio_class {width:60px}
.coord_label {font-size:10; border-style:none; width:60px}
.label {height: 13px; font-size:10; border-style:none; width:35px}
.values {font-size:12; border-style:none; width:120px}
.area {background-color:yellow;border-style:none;width:80px}
</style>
<!INPUT {color:black; font-size:10; border-style:thin; border-color:white; border-style:none; height:15px; width:80px}>
<script type=text/javascript language=javascript><!--
//window.scrollbars.visible;
//******* *******
//******* *******
//******* *******
//******* modul variables *******
//******* *******
//******* *******
//******* *******
// array for variables and names
var value_field = new Array (11);
var var_plot = new Array (37);
var var_mass= new Array(30);
// public constants
rnds=1000000;
Pi=3.1415927;
theta_step=10;
calc=false;
opti_flag=0;
measure_system='metric';
// public variables
var b;
var c;
var output_values;
var output2_values;
var output3_values;
//var y_;
//var flag;
var measure_flag;
var opt_flag;
var m_area_text;
var id_;
var id2_;
var cursorY;
var cursorX;
//var vclc;
//var vswc;
//var vcle;
//var vswe;
//var dcomp;
//var dexp;
//var b1;
//var b2;
//var crank;
var acomp;
var aexp;
//var yoke;
//var ymax;
var ymin;
//var vswc;
//var vswe;
//var thmaxe;
//var thmaxc;
//var thmine;
//var thminc;
var alpha;
var phase;
//var yoke_vswc;
//var yoke_vswe;
//var msg0;
var awgk;
var dk;
var lk;
var v;
var a;
var awg;
var d;
var awgh;
var dh;
var lh;
var douth;
var dinh;
var cqwr;
var dqwr;
var msg;
var msg_ges;
var objFile2;
var objFso2;
var vc;
var ve;
var gama;
var cp;
var cv;
// plotpv
var deg = new Array (361);
var vep = new Array (361);
var vcp = new Array (361);
var vtp = new Array (361);
var vp = new Array (361);
// adiabatic
var crank;
var b1;
var b2;
var acomp;
var aexp;
var dve;
var dvc;
var y = new Array (38);
var dy = new Array (38);
var y0 = new Array (38);
var dy1= new Array (38);
var dy2= new Array (38);
var dy3= new Array (38);
var dy4= new Array (38);
var var_ = new Array (38);
var dvar = new Array (38);
//simple
// var def before adiabatic function ->
// diagram
var plot_var =new Array (37);
var plot_scl = new Array (37);
// Row indices of the var, dvar matrices, and the y,dy variable vectors:
TC_i = 1; // Compression space temperature (K)
TE_i = 2; // Expansion space temperature (K)
QK_i = 3; // Heat transferred to the cooler (J)
QR_i = 4; // Heat transferred to the regenerator (J)
QH_i = 5; // Heat transferred to the heater (J)
WC_i = 6; // Work done by the compression space (J)
WE_i = 7; // Work done by the expansion space (J)
W_i = 8; // Total work done (WC + WE) (J)
P_i = 9; // Pressure (Pa)
VC_i = 10; // Compression space volume (m^3)
VE_i = 11; // Expansion space volume (m^3)
MC_i = 12; // Mass of gas in the compression space (kg)
MK_i = 13; // Mass of gas in the cooler (kg)
MR_i = 14; // Mass of gas in the regenerator (kg)
MH_i = 15; // Mass of gas in the heater (kg)
ME_i = 16; // Mass of gas in the expansion space (kg)
TCK_i = 17; // Conditional temperature compression space / cooler (K)
THE_i = 18; // Conditional temeprature heater / expansion space (K)
GACK_i = 19; // Conditional mass flow compression space / cooler (kg/rad)
GAKR_i = 20; // Conditional mass flow cooler / regenerator (kg/rad)
GARH_i = 21; // Conditional mass flow regenerator / heater (kg/rad)
GAHE_i = 22; // Conditional mass flow heater / expansion space (kg/rad)
gAk=23;
gAr=24;
gAh=25;
REYKOL=26;
REYREG=27;
REYHOT=28;
DPKOL=29;
DPREG=30;
DPHOT=31;
// Size of var(ROWV,COL), y(ROWV), dvar(ROWD,COL), dy(ROWD)
ROWV = 22; // number of rows in the var matrix
ROWD = 16; // number of rows in the dvar matrix
COL = 37; // number of columns in the matrices (every 10 degrees)
// create multidimensional array
// 2. dimension
for (var i = 0; i < value_field.length; ++i)
value_field[i] = new Array(11);
// 3. dimension
for (var i = 0; i < value_field.length; ++i)
{
for (var j = 0; j < value_field.length; j++)
value_field[i][j] = new Array(11);
}
// 4. dimension
for (var i = 0; i < value_field.length; ++i)
{
//alert (value_field.length)
for (var j = 0; j < value_field.length; j++)
{
for (var k = 0; k < value_field.length; ++k)
value_field[i][j][k] = new Array(11);
}
}
// create multidimensional array
// 2. dimension
for (var i = 0; i <= 37; ++i)
var_plot[i] = new Array(361);
// create multidimensional array
// 2. dimension
for (var i = 0; i <= 30; ++i)
var_mass[i] = new Array(361);
// create multidimensional array
// 2. dimension
for (var i = 0; i <= 37; ++i)
var_[i] = new Array(37);
// create multidimensional array
// 2. dimension
for (var i = 0; i <= 37; ++i)
dvar[i] = new Array(37);
// create multidimensional array
// 2. dimension
for (var i = 0; i <= 37; ++i) plot_var[i] = new Array(37);
// 3. dimension
for (var i = 0; i <= 37; ++i)
{
for (var j = 0; j <= 37; j++) plot_var[i][j] = new Array(361);
}
// create multidimensional array
// 2. dimension
for (var i = 0; i <= 37; ++i)
plot_scl[i] = new Array(37);
//******* *******
//******* *******
//******* *******
//******* modul layout *******
//******* *******
//******* *******
//******* *******
var cm_inch;
var mm_inch;
var mm1_inch1;
var mm2_inch2;
var cm2_inch2;
var cm3_inch3;
var m_ft;
var m1_ft1;
var measure_system;
document.open();
// document.writeln("<style type="text/css"></style>")
document.writeln("<h2>please proof results --- Stirling engines --- Javascript needed, tested with Opera browser (9.62)</h2>");
document.writeln("<h5><a href=http://www.ent.ohiou.edu/~urieli/stirling/me422.html>www.ent.ohiou.edu</a></h5><br><br><br><br><br><br><br><br><br><br><br><br><br>");
document.writeln("<div xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dct=\"http://purl.org/dc/terms/\" about=\"http://www.ohio.edu/mechanical/thermo/index.html\"><span property=\"dct:title\">\n<font size=\"+1\">Engineering Thermodynamics</font></span> (<a rel=\"cc:attributionURL\" property=\"cc:attributionName\" href=\"http://www.ohio.edu/mechanical/thermo\">Israel Urieli</a>) / <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc-sa/3.0/us/\">CC BY-NC-SA 3.0</a></div>");
document.writeln("<Table id='div_menue' border='0' style='position:absolute; left:10px; top:80px; visibility=visible'>");
document.writeln("<tr><td>");
document.writeln("<INPUT type='radio' class='radio_class' onmousedown=radio0_2.checked == false onmouseout=measure_sys_sub() id='radio0_1' name='radio'>'inchlike' values</td>");
document.writeln("<td>");
document.writeln("<INPUT type='radio' class='radio_class' onmousedown=radio0_1.checked == false onmouseout=measure_sys_sub() id='radio0_2' name='radio'>metric values</td></tr>");
document.writeln("<tr><td><INPUT type='radio' class='radio_class' onclick=define() id=radio1_1 name='radio2' unchecked>alpha Urieli");
document.writeln("<INPUT type='radio' class='radio_class' onclick=define() id=radio1_5 name='radio2' checked>gamma Urieli");
document.writeln("<INPUT type='radio' class='radio_class' onclick=define() id=radio1_2 name='radio2' unchecked>alpha Hirata");
document.writeln("<INPUT type='radio' class='radio_class' onclick=define() id=radio1_3 name='radio2' unchecked>beta Hirata");
document.writeln("<INPUT type='radio' class='radio_class' onclick=define() id=radio1_4 name='radio2' unchecked>gamma Hirata");
document.writeln("</tr></td>");
document.writeln("<tr><td>");
document.writeln("<INPUT type='radio' class='radio_class' onchange=define() id=radio2_1 name='radio3' unchecked>diagram - offset");
document.writeln("<INPUT type='radio' class='radio_class' onchange=define() id=radio2_2 name='radio3' checked>diagram no offset");
document.writeln("</tr></td></table><Table>");
if (measure_system=='inch') {
//alert ("inch");
radio0_1.checked='checked';
mm_inch="inch";
mm1_inch1=1000;
mm2_inch2=10000;
cm_inch="inch";
cm2_inch2=10000;
cm3_inch3=1000000;
m_ft="ft";
m1_ft1=1;
}
if (measure_system=='metric') {
//alert ("metric");
radio0_2.checked='checked';
mm_inch="mm";
mm1_inch1=1000;
mm2_inch2=10000;
cm_inch="cm";
cm2_inch2=10000;
cm3_inch3=1000000;
m_ft="m";
m1_ft1=1;
}
// define measure system
value_field[0][1][0][0] = "measure_system";
value_field[0][1][1][0] = "inch";
value_field[0][1][2][0] = "metric";
// define engine type
// value_field[0][0][0][0][0] = "engine type";
// value_field[1][0][0][0][0] = "alpha type";
// value_field[2][0][0][0][0] = "beta type";
// value_field[3][0][0][0][0] = "gamma type";
// ...
// define drive variables
value_field[1][0][0][0] = "drive configuration";
value_field[1][1][0][0] = "sin_drive";
value_field[1][1][1][0] = "comp clearence vol";
value_field[1][1][1][1] = "cm_inch_3";
value_field[1][1][1][2] = 'sin_vclc';
value_field[1][1][2][0] = "comp swept vol";
value_field[1][1][2][1] = "cm_inch_3";
value_field[1][1][2][2] = "sin_vswc";
value_field[1][1][3][0] = "exp clearence vol";
value_field[1][1][3][1] = "cm_inch_3";
value_field[1][1][3][2] = "sin_vcle";
value_field[1][1][4][0] = "exp swept vol";
value_field[1][1][4][1] = "cm_inch_3";
value_field[1][1][4][2] = "sin_vswe";
value_field[1][1][5][0] = "exp phase angle advance";
value_field[1][1][5][1] = "degree";
value_field[1][1][5][2] = "sin_phase";
value_field[1][2][0][0] = "Yoke drive";
value_field[1][2][1][0] = "comp clearence vol";
value_field[1][2][1][1] = "cm_inch_3";
value_field[1][2][1][2] = 'yoke_vclc';
value_field[1][2][2][0] = "comp swept vol";
value_field[1][2][2][1] = "cm_inch_3";
value_field[1][2][2][2] = "yoke_vswc";
value_field[1][2][3][0] = "exp clearence vol";
value_field[1][2][3][1] = "cm_inch_3";
value_field[1][2][3][2] = "yoke_vcle";
value_field[1][2][4][0] = "exp swept vol";
value_field[1][2][4][1] = "cm_inch_3";
value_field[1][2][4][2] = "yoke_vswe";
value_field[1][2][5][0] = "yoke length b1 [1/2 yoke base]";
value_field[1][2][5][1] = "mm_inch";
value_field[1][2][5][2] = "yoke_b1";
value_field[1][2][6][0] = "yoke height b2";
value_field[1][2][6][1] = "mm_inch";
value_field[1][2][6][2] = "yoke_b2";
value_field[1][2][7][0] = "crank radius";
value_field[1][2][7][1] = "mm_inch";
value_field[1][2][7][2] = "yoke_crank";
value_field[1][2][8][0] = "comp-working piston diameter";
value_field[1][2][8][1] = "mm_inch";
value_field[1][2][8][2] = "yoke_dcomp";
value_field[1][2][9][0] = "exp-displacer piston diameter";
value_field[1][2][9][1] = "mm_inch";
value_field[1][2][9][2] = "yoke_dexp";
value_field[1][3][0][0] = "Rhombic drive";
//value_field[1][3][1][0] = "comp clearence vol";
//value_field[1][3][1][1] = "cm_inch_3";
//value_field[1][3][1][2] = 'rhomb_vclc';
//...
//define cooler variables
value_field[2][1][0][0] = "smooth cylinder surface";
value_field[2][1][1][0] = "cylinder inside diameter";
value_field[2][1][1][1] = "mm_inch";
value_field[2][1][1][2] = "c_smo_a";
value_field[2][1][2][0] = "cylinder exchanger length";
value_field[2][1][2][1] = "mm_inch";
value_field[2][1][2][2] = "c_smo_lk";
value_field[2][1][3][0] = "number of cylinders";
value_field[2][1][3][2] = "c_smo_num";
value_field[2][2][0][0] = "homogeneous bundle of smooth pipes";
value_field[2][2][1][0] = "pipe inside diameter";
value_field[2][2][1][1] = "mm_inch";
value_field[2][2][1][2] = "c_pi_din";
value_field[2][2][2][0] = "heat exchanger length";
value_field[2][2][2][1] = "mm_inch";
value_field[2][2][2][2] = "c_pi_lk";
value_field[2][2][3][0] = "number of pipes in bundle";
value_field[2][2][3][2] = "c_pi_num";
value_field[2][3][0][0] = "annular gap heat exchanger";
value_field[2][3][1][0] = "annular gap outer diameter";
value_field[2][3][1][1] = "mm_inch";
value_field[2][3][1][2] = "c_an_dout";
value_field[2][3][2][0] = "annular gap inner diameter";
value_field[2][3][2][1] = "mm_inch";
value_field[2][3][2][2] = "c_an_din";
value_field[2][3][3][0] = "heat exchanger length";
value_field[2][3][3][1] = "mm_inch";
value_field[2][3][3][2] = "c_an_lk";
value_field[2][4][0][0] = "slot heat exchanger";
value_field[2][4][1][0] = "width of slot";
value_field[2][4][1][1] = "mm_inch";
value_field[2][4][1][2] = "c_sl_w";
value_field[2][4][2][0] = "hight of slot";
value_field[2][4][2][1] = "mm_inch";
value_field[2][4][2][2] = "c_sl_h";
value_field[2][4][3][0] = "heat exchanger length";
value_field[2][4][3][1] = "mm_inch";
value_field[2][4][3][2] = "c_sl_lk";
value_field[2][4][4][0] = "number of slots";
value_field[2][4][4][2] = "c_sl_num";
value_field[2][5][0][0] = "pin heat exchanger";
value_field[2][5][1][0] = "dia of pin";
value_field[2][5][1][1] = "mm_inch";
value_field[2][5][1][2] = "c_pin_w";
value_field[2][5][2][0] = "hight of pin";
value_field[2][5][2][1] = "mm_inch";
value_field[2][5][2][2] = "c_pin_h";
value_field[2][5][3][0] = "filling percentage with pins";
value_field[2][5][3][1] = "";
value_field[2][5][3][2] = "c_pin_fl";
value_field[2][5][4][0] = "number of pins";
value_field[2][5][4][2] = "c_pin_num";
//define regenerator variables
value_field[3][1][0][0] = "regenerating cylinder surface only";
value_field[3][1][1][0] = "regenerator void volume";
value_field[3][1][1][1] = "cm_inch_3";
value_field[3][1][1][2] = "r_vol_vr";
value_field[3][2][0][0] = "regenerating displacer";
value_field[3][2][1][0] = "regenerator void volume";
value_field[3][2][1][1] = "cm_inch_3";
value_field[3][2][1][2] = "r_disp_vr";
value_field[3][3][0][0] = "tubular regenerating housing";
value_field[3][3][1][0] = "tubular external dia";
value_field[3][3][1][1] = "mm_inch";
value_field[3][3][1][2] = "r_tub_dout";
value_field[3][3][2][0] = "tubular internal dia";
value_field[3][3][2][1] = "mm_inch";
value_field[3][3][2][2] = "r_tub_din";
value_field[3][3][3][0] = "tubular length reg";
value_field[3][3][3][1] = "mm_inch";
value_field[3][3][3][2] = "r_tub_lr";
value_field[3][3][4][0] = "tubular number tubes";
value_field[3][3][4][2] = "r_tub_num";
value_field[3][4][0][0] = "annular regenerating housing";
value_field[3][4][1][0] = "annular external dia";
value_field[3][4][1][1] = "mm_inch";
value_field[3][4][1][2] = "r_an_dout";
value_field[3][4][2][0] = "annular internal dia";
value_field[3][4][2][1] = "mm_inch";
value_field[3][4][2][2] = "r_an_din";
value_field[3][4][3][0] = "annular matrix internal dia";
value_field[3][4][3][1] = "mm_inch";
value_field[3][4][3][2] = "r_an_dimat";
value_field[3][4][4][0] = "annular length reg";
value_field[3][4][4][1] = "mm_inch";
value_field[3][4][4][2] = "r_an_lr";
//define matrix variables
value_field[4][1][0][0] = "no matrix";
value_field[4][1][1][0] = "m_no";
value_field[4][1][1][2] = "m_no";
value_field[4][2][0][0] = "stacked wire mesh matrix";
value_field[4][2][1][0] = "regenerator matrix porosity:";
value_field[4][2][1][2] = "m_mesh_por";
value_field[4][2][2][0] = "regenerator matrix wire diam";
value_field[4][2][2][1] = "mm_inch";
value_field[4][2][2][2] = "m_mesh_dwire";
value_field[4][2][3][0] = "volumetric heat capacity";
value_field[4][2][3][1] = "J/cm3/K";
value_field[4][2][3][2] = "m_mesh_csm";
value_field[4][3][0][0] = "wrapped foil matrix";
value_field[4][3][1][0] = "regenerator porosity";
//value_field[4][3][1][1] = "mm_inch";
value_field[4][3][1][2] = "m_foil_por";
value_field[4][3][2][0] = "regenerator unrolled foil length";
value_field[4][3][2][1] = "m_ft";
value_field[4][3][2][2] = "m_foil_lm";
value_field[4][3][3][0] = "regenerator foil thickness";
value_field[4][3][3][1] = "mm_inch";
value_field[4][3][3][2] = "m_foil_th";
value_field[4][3][4][0] = "volumetric heat capacity";
value_field[4][3][4][1] = "J/cm3/K";
value_field[4][3][4][2] = "m_foil_csm";
//define heater variables
value_field[5][1][0][0] = "smooth cylinder surface";
value_field[5][1][1][0] = "cylinder inside area";
value_field[5][1][1][1] = "cm_inch_2";
value_field[5][1][1][2] = "h_smo_a";
value_field[5][1][2][0] = "cylinder exchanger length";
value_field[5][1][2][1] = "mm_inch";
value_field[5][1][2][2] = "h_smo_lh";
value_field[5][1][3][0] = "number of cylinders";
value_field[5][1][3][2] = "h_smo_num";
value_field[5][2][0][0] = "homogeneous bundle of smooth pipes";
value_field[5][2][1][0] = "pipe inside diameter";
value_field[5][2][1][1] = "mm_inch";
value_field[5][2][1][2] = "h_pi_din";
value_field[5][2][2][0] = "heat exchanger length";
value_field[5][2][2][1] = "mm_inch";
value_field[5][2][2][2] = "h_pi_lh";
value_field[5][2][3][0] = "number of pipes in bundle";
value_field[5][2][3][2] = "h_pi_num";
value_field[5][3][0][0] = "annular gap heat exchanger";
value_field[5][3][1][0] = "annular_gap_outer_diameter";
value_field[5][3][1][1] = "mm_inch";
value_field[5][3][1][2] = "h_an_dout";
value_field[5][3][2][0] = "annular gap inner diameter";
value_field[5][3][2][1] = "mm_inch";
value_field[5][3][2][2] = "h_an_din";
value_field[5][3][3][0] = "heat exchanger length";
value_field[5][3][3][1] = "mm_inch";
value_field[5][3][3][2] = "h_an_lh";
value_field[5][4][0][0] = "slot heat exchanger";
value_field[5][4][1][0] = "width of slot";
value_field[5][4][1][1] = "mm_inch";
value_field[5][4][1][2] = "h_sl_w";
value_field[5][4][2][0] = "hight of slot";
value_field[5][4][2][1] = "mm_inch";
value_field[5][4][2][2] = "h_sl_h";
value_field[5][4][3][0] = "heat exchanger length";
value_field[5][4][3][1] = "mm_inch";
value_field[5][4][3][2] = "h_sl_lh";
value_field[5][4][4][0] = "number of slots";
value_field[5][4][4][2] = "h_sl_num";
value_field[5][5][0][0] = "pin heat exchanger";
value_field[5][5][1][0] = "dia of pin";
value_field[5][5][1][1] = "mm_inch";
value_field[5][5][1][2] = "c_pin_w";
value_field[5][5][2][0] = "hight of pin";
value_field[5][5][2][1] = "mm_inch";
value_field[5][5][2][2] = "c_pin_h";
value_field[5][5][3][0] = "filling percentage with pins";
value_field[5][5][3][1] = "";
value_field[5][5][3][2] = "c_pin_fl";
value_field[5][5][4][0] = "number of pins";
value_field[5][5][4][2] = "c_pin_num";
//define gas type
value_field[6][0][1][2] = "gas type";
value_field[6][1][0][0] = "hydrogen";
value_field[6][1][1][2] = "hydrogen";
value_field[6][2][0][0] = "helium";
value_field[6][2][1][2] = "helium";
value_field[6][3][0][0] = "air";
value_field[6][3][1][2] = "air";
//define operating parameter variables
value_field[7][1][0][0] = "operating parameters";
value_field[7][1][1][0] = "Mean pressure [kPa]";
value_field[7][1][1][2] = "op_pmean";
value_field[7][1][2][0] = "Cold sink temperature [K]";
value_field[7][1][2][2] = "op_tk";
value_field[7][1][3][0] = "Hot source temperature [K]";
value_field[7][1][3][2] = "op_th";
value_field[7][1][4][0] = "Effective regenerator temperature [K]";
value_field[7][1][4][2] = "op_tr";
value_field[7][1][5][0] = "Operating frequency [Hz]";
value_field[7][1][5][2] = "op_freq";
for (a=1; a<=7; a++)
{
for (b=1; b<=9; b++)
{
c=0;
lleft=b * 250 - 240 ;
ltop=a * 350 + 150;
//alert (lleft + " " + ltop );
if (value_field[a][b][1][2]) {
document.writeln("<Tr><Td id='td" + a + "_" + b + "' style='position:absolute; left:" + lleft + "px; top:" + ltop + "px' >");
// for example: writes "comp clearence vol [" + cm_inch + "]"
document.writeln("<INPUT type='checkbox' class='check_class' id=checkbox" + a + "_" + b + " name=check_" +
value_field[a][b][1][2] + "><font>" + value_field[a][b][c][0] + "</font><br>");
document.writeln("<Div id='div_m" + a + "_" + b + "' style=''><br>");
}
for (c=1; c<=9; c++)
{
//alert (value_field[a][b][c][0] + " " + value_field[a][b][c][2])
if (value_field[a][b][c][0] && value_field[a][b][c][2])
{
// for e. g.: writes "sin_vclc"
//if (a==1 && b==1) alert (value_field[a][b][c][0] + value_field[a][b][c][2] );
if (value_field[a][b][c][1] ) document.writeln("<Label >"+ value_field[a][b][c][0] + " [" + "<Input class='label' id=" + a +"_" + b +"_" + c + "_" + value_field[a][b][c][1] + " value="+ value_field[a][b][c][1] +
">"+"]"+"</label><br><INPUT class='values' onclick=define() ondblclick=javascript:optimum_value(this) onmouseover=calc=true onkeyup=javascript:key(this) onmouseout=calc=false onchange=checkbox" + a + "_" + b + ".checked=true id=" + value_field[a][b][c][2] +
" name=" + value_field[a][b][c][2] + "><br>");
if (!value_field[a][b][c][1] ) document.writeln("<Label >"+ value_field[a][b][c][0] +
"</label><br><INPUT class='values' onclick=define() ondblclick=javascript:optimum_value(this) onmouseover=calc=true onkeyup=javascript:key(this) onmouseout=calc=false onchange=checkbox" + a + "_" + b + ".checked=true id=" + value_field[a][b][c][2] +
" name=" + value_field[a][b][c][2] + "><br>");
// alert value_field[a][b][c][0];
}
}
document.writeln("</Div>");
document.writeln("<br>");}
}
// seems to be working not correctly - order of closing tags
document.writeln("</td></tr></Table>");
document.writeln("<Div id='div_m_area' style='visibility:hidden;position:absolute'>");
document.writeln("<Table>");
document.writeln("<Tr><Td><INPUT class='area' ondblclick=optimum_value() onmouseover=window.defaultStatus=id id='m_area_inp' ></Td>");
document.writeln("<Td><INPUT class='area' ondblclick=optimum_value2() onmouseover=window.defaultStatus=id id='m_area_inp2' ></Td>");
document.writeln("<Td><select onchange=value_area() class='area' id='m_area_select' size=1 ><option value=1>+-1%<option value=5>+-5%<option value=10>+-10%<option value=20>+-20%<option value=50>+-50%</select></Td></Tr>");
document.writeln("</Table></Div>");
document.writeln("<Table><Tr><Td><div id=table_schm style='position:absolute; left:1050px; top:10px; visibility=hidden'>");
document.writeln("<Label>Schmidt analysis results:</Label><br>");
document.writeln("<Label>Work(joules)</Label><INPUT class='values' id='w_schm'><br>");
document.writeln("<Label>Power(watts)</Label><INPUT class='values' id='power_schm'><br>");
document.writeln("<Label>Qexp(joules)</Label><INPUT class='values' id='we_schm'><br>");
document.writeln("<Label>Qcom(joules)</Label><INPUT class='values' id='wc_schm'><br>");
document.writeln("<Label>indicated efficiency</Label><INPUT class='values' id='eff_schm'><br>");
document.writeln("<Label>regen wall heat leakage</Label><INPUT class='values' id='regleak_schm'><br>");
document.writeln("<Label>ratio V_max/V_unswept</Label><INPUT class='values' id='ratio_vsw_max_vsw_min'><br>");
document.writeln("<Label>ratio p_max/p_min</Label><INPUT class='values' id='ratio_p_max_p_min'><br>");
document.writeln("</div></td></tr></table>");
document.writeln("<Table><Tr><Td><div id=table_adiab style='position:absolute; left:1050px; top:450px; visibility=hidden'>");
document.writeln("<Label>Ideal Adiabatic analysis results:</Label><br>");
document.writeln("<Label>Heat transferred to the cooler(watts): </Label><br><INPUT class='values' id='qk_adiab'><br>");
document.writeln("<Label>Net heat transferred to the regenerator(watts):</Label><br><INPUT class='values' id='qr_adiab'><br>");
document.writeln("<Label>Heat transferred to the heater(watts):</Label><br><INPUT class='values' id='qh_adiab'><br>");
document.writeln("<Label>Total power output(watts):</Label><br><INPUT class='values' id='w_adiab'><br>");
document.writeln("<Label>Thermal efficiency: </Label><br><INPUT class='values' id='eff_adiab'><br>");
document.writeln("</div></td></tr></table>");
document.writeln("<Table><Tr><Td><div id=table_simple style='position:absolute; left:1050px; top:650px; visibility=hidden'>");
document.writeln("<Label>Simple analysis results:</Label><br>");
document.writeln("<Label>Heat transferred to the cooler(watts): </Label><br><INPUT class='values' id='qk_simple'><br>");
document.writeln("<Label>Net heat transferred to the regenerator(watts):</Label><br><INPUT class='values' id='qr_simple'><br>");
document.writeln("<Label>Heat transferred to the heater(watts):</Label><br><INPUT class='values' id='qh_simple'><br>");
document.writeln("<Label>Total power output(watts):</Label><br><INPUT class='values' id='w_simple'><br>");
document.writeln("<Label>Thermal efficiency: </Label><br><INPUT class='values' id='eff_simple'><br>");
document.writeln("</div></td></tr></table>");
// define menue
document.writeln("<INPUT type='button' value='reload' onclick=window.location.reload() name='reload' style='position:absolute; left:20; top:40'>");
//document.writeln("<INPUT type='button' value='forward' onclick=javascript:script_href() name='forward' style='position:absolute; left:120; top:40'>");
document.writeln("<INPUT type='button' value='menue slide' onclick=slide_menue() name='hide_show' style='position:absolute; left:150; top:40'>");
document.writeln("<INPUT type='button' value='stim_output' onclick=javascript:input2() name='stim_output' style='position:absolute; left:1050; top:900'>");
document.writeln("<INPUT type='button' value='stim_input' onclick=javascript:input() name='stim_input' style='position:absolute; left:1050; top:920'>");
document.writeln("<div id='div_textarea' style='visibility:visible; position:absolute; left:1250; top:10'><textarea id='output' name='output' cols='500' rows='40' ></textarea></div>");
document.writeln("<div id='div_textarea2' style='visibility:visible; position:absolute; left:1250; top:680'><textarea id='output2' name='output2' cols='500' rows='20' ></textarea></div>");
document.writeln("<div id='div_textarea3' style='visibility:visible; position:absolute; left:1250; top:1030'><textarea id='output3' name='output3' cols='500' rows='50' ></textarea></div>");
//document.close();
function slide_menue()
{
if (!calc) {
obj=document.getElementById("div_m_area");
obj.style.visibility="hidden"
for (a=1; a<=8; a++) {
for (b=1; b<=5; b++) {
if (value_field[a][b][1][2]) {
objs=document.getElementById("td" + a + "_" + b);
if (objs.style.top=="500px") objs.style.top="2950px";
//alert (parseFloat(objs.style.top));
if (parseFloat(objs.style.top)>500 ) {
objs.style.top=parseFloat(objs.style.top)-350;
}
}
}
}
}
}
function measure_sys_sub()
{
if (radio0_1.checked==true) measure_system="inch";
if (radio0_2.checked==true) measure_system="metric";
//alert ("measure_sys_sub: " + measure_system);
//values_to_file();
//document.location.reload();
if (measure_system=='inch') {
//alert ("inch");
radio0_1.checked='checked';
for (a=1; a<=7; a++) {
for (b=1; b<=9; b++){
for (c=1; c<=9; c++) {
if (document.getElementById(a+"_"+b+"_"+c+"_mm_inch")) {
document.getElementById(a+"_"+b+"_"+c+"_mm_inch").value="inch";
mm1_inch1=1000;
objs=document.getElementById(value_field[a][b][c][2] );
if (measure_flag=="cm") objs.value=(objs.value/(25.4)*1000000)/1000000;
}
if (document.getElementById(a+"_"+b+"_"+c+"_cm_inch_2")) {
document.getElementById(a+"_"+b+"_"+c+"_cm_inch_2").value="inch²";
cm2_inch2=10000;
objs=document.getElementById(value_field[a][b][c][2] );
if (measure_flag=="cm") objs.value=(objs.value/(2.54*2.54)*10000)/10000;
}
if (document.getElementById(a+"_"+b+"_"+c+"_cm_inch_3")) {
document.getElementById(a+"_"+b+"_"+c+"_cm_inch_3").value="inch³";
cm3_inch3=1000000;
objs=document.getElementById(value_field[a][b][c][2] );
if (measure_flag=="cm") objs.value=(objs.value/(2.54*2.54*2.54)*1000000)/1000000;
}
if (document.getElementById(a+"_"+b+"_"+c+"_m_ft")) {
document.getElementById(a+"_"+b+"_"+c+"_m_ft").value="ft";
m1_ft1=1;
objs=document.getElementById(value_field[a][b][c][2] );
if (measure_flag=="cm") objs.value=(objs.value*(3.2809)*1000)/1000;
}
}}}
measure_flag="inch";
}
if (measure_system=='metric') {
//alert ("metric");
radio0_2.checked='checked';
for (a=1; a<=7; a++){
for (b=1; b<=9; b++){
for (c=1; c<=9; c++){
if (document.getElementById(a+"_"+b+"_"+c+"_mm_inch")) {
document.getElementById(a+"_"+b+"_"+c+"_mm_inch").value="mm";
mm1_inch1=1000;
objs=document.getElementById(value_field[a][b][c][2] );
if (measure_flag=="inch") objs.value=(objs.value*(25.4)*1000)/1000;
}
if (document.getElementById(a+"_"+b+"_"+c+"_cm_inch_2")) {
document.getElementById(a+"_"+b+"_"+c+"_cm_inch_2").value="cm²";
cm2_inch2=10000;
objs=document.getElementById(value_field[a][b][c][2] );
if (measure_flag=="inch") objs.value=(objs.value*(25.4)*10000)/10000;
}
if (document.getElementById(a+"_"+b+"_"+c+"_cm_inch_3")) {
document.getElementById(a+"_"+b+"_"+c+"_cm_inch_3").value="cm³";
cm3_inch3=1000000;
objs=document.getElementById(value_field[a][b][c][2] );
if (measure_flag=="inch") objs.value=(objs.value*(2.54*2.54*2.54)*1000000)/1000000;
}
if (document.getElementById(a+"_"+b+"_"+c+"_m_ft")) {
document.getElementById(a+"_"+b+"_"+c+"_m_ft").value="m";
m1_ft1=1;
objs=document.getElementById(value_field[a][b][c][2] );
if (measure_flag=="inch") objs.value=(objs.value/(3.2809)*1000)/1000;
}
}}}
measure_flag="cm";
}
}
//******* *******
//******* *******
//******* *******
//******* modul help *******
//******* *******
//******* *******
//******* *******
document.writeln("<INPUT type='button' value='help' onclick=javascript:help() name='help' style='position:absolute; left:600; top:40'>");
function help(){
window.open('help.htm', 'windowname', 'height=320, width=450, left=700, top=50, scrollbars, resizable');
}
//--></script>
<meta http-equiv="Pragma" content="no-cache">
<meta name="Keywords" content="science">
<meta name="Description" content="science">
</HEAD>
<body background="2004-0.jpg" bgproperties="fixed" onload=measure_sys_sub() >
<!img src="2004-04.jpg" background="2004-04.jpg">
<script type=text/javascript language=javascript><!--
//******* *******
//******* *******
//******* *******
//******* modul layout-tools *******
//******* *******
//******* *******
//******* *******
// optimisation
var opti_ind = new Array (20);
var msg_id = new Array(10);
//cursor
var cursorX;
var cursorY;
//document.onkeyup= key;
function key(id_){
//key_event=window.event.keycode;
//alert (window.event.keyCode);
if (window.event.keyCode== 13) optimum_values_multiple_choice();
if (window.event.keyCode==16) optimum_value(id_);
}
document.onmousemove = mouse_pos;
function mouse_pos () {
event_ = window.event;
cursorY=event_.screenY;
cursorX=event_.screenX;
window.defaultStatus="cursorY " + cursorY + " cursorX " + cursorX;
//window.status="cursorY " + cursorY + " cursorX " + cursorX;
}
function value_area(){
obj=document.getElementById("m_area_inp");
obj2=document.getElementById("m_area_inp2");
obj3=document.getElementById("m_area_select");
part=obj.value * (1+ obj3.value / 100);
obj2.value=obj.value*(1 - obj3.value / 100 ) + " - " + part;
}
function optimum_value2(id_){ id_=id2_;
optimum_values_multiple_choice();
id_max=0;
power_schm_max=0;
a_max=10;
for (a__=0; a__<=a_max; a__++){
obj=document.getElementById("m_area_inp");
obj2=document.getElementById("m_area_inp2");
obj3=document.getElementById("m_area_select");
id_.value=obj.value*(1 - obj3.value / 100 ) + 2*a__/(a_max)*obj.value * obj3.value / 100;
define();
//simple();
//alert (id_.value + " power_schm " + power_schm.value + " "+power_schm_max+ " id_max "+ id_max + " " + a__);
//if (power_schm_max<=actWpower) {
//power_schm_max=actWpower;
if (power_schm_max<=power) {
power_schm_max=power;
id_max=id_.value;
}
}
id_.value=id_max;
obj=document.getElementById("m_area_inp");
obj.value=id_.value ;
define();
//simple();
obj=document.getElementById("div_m_area");
obj.style.visibility="hidden";
}
function optimum_value(id_){
obj=document.getElementById("div_m_area");
if (obj.style.visibility=="hidden"){
obj.style.visibility="visible"}
else {
obj.style.visibility="hidden"
m_area_inp2.value="";
}
if (txt.search("MSIE 6.0")>=0 && (navigator.userAgent.search("Opera")>0)) {
obj.style.pixelTop= cursorY; //-120;
obj.style.pixelLeft= cursorX;
//alert("MSIE 6.0 cursorY " + cursorY + "\ncursorX " + cursorX);
output3.value=("MSIE 6.0 cursorY " + cursorY + "\ncursorX " + cursorX);
}
else {
obj.style.top=cursorY; //-120;
//obj.style.left=cursorX;
obj.style.left=10;
//alert("cursorY " + cursorY + "\ncursorX " + cursorX);
output3.value=(" cursorY " + cursorY + "\ncursorX " + cursorX);
}
obj=document.getElementById("m_area_inp");
obj.value=id_.value ;
obj2=document.getElementById("m_area_inp2"); obj3=document.getElementById("m_area_select");
part=obj.value * (1+ obj3.value / 100);
obj2.value=obj.value*(1 - obj3.value / 100 ) + " - " + part;
id2_=id_;
}
function optimum_values_multiple_choice(){
msg="";
for (a=1; a<=7; a++){
opti_ind[a]="";
}
for (a=1; a<=7; a++){
for (b=1; b<=5; b++){
opt_obj=document.getElementById("checkbox" + a + "_" + b);
if (opt_obj && opt_obj.checked) opti_ind[a]=opti_ind[a]+"1";
if (opt_obj && !opt_obj.checked) opti_ind[a]=opti_ind[a]+"0"; }
msg = msg + opti_ind[a] + "\n" ;
}
opti_ind[10]=-100000;
l=0;
//if (opt_flag!=1){
a=1;
a2=1;
a3=1;
a4=1;
a5=1;
a6=1;
a7=1;
a8=1;
msg2="";
msg3="";
msg4="";
msg5="";
msg6="";
msg7="";
msg8="";
opt_flag=1;
//}
while (a8<=opti_ind[1].length) {
while (a<=opti_ind[1].length) {
if (a8==a) msg8=msg8 + "1";
if (a8!=a) msg8=msg8 + "0";
a++;
}
a=1;
while (a7<=opti_ind[2].length) {
while (a<=opti_ind[2].length) {
if (a7==a) msg7=msg7 + "1";
if (a7!=a) msg7=msg7 + "0";
a++; }
a=1;
while (a6<=opti_ind[3].length) {
while (a<=opti_ind[3].length) {
if (a6==a) msg6=msg6 + "1";
if (a6!=a) msg6=msg6 + "0";
a++;
}
a=1;
while (a5<=opti_ind[4].length) {
while (a<=opti_ind[4].length) {
if (a5==a) msg5=msg5 + "1";
if (a5!=a) msg5=msg5 + "0";
a++;
}
a=1;
while (a4<=opti_ind[5].length) {
while (a<=opti_ind[5].length) {
if (a4==a) msg4=msg4 + "1";
if (a4!=a) msg4=msg4 + "0";
a++;
}
a=1;
while (a3<=opti_ind[6].length) {
while (a<=opti_ind[6].length) {
if (a3==a) msg3=msg3 + "1";
if (a3!=a) msg3=msg3 + "0";
a++;
}
a=1;
while (a2<=opti_ind[7].length) {
while (a<=opti_ind[7].length) {
if (a2==a) msg2=msg2 + "1";
if (a2!=a) msg2=msg2 + "0";
a++;
}
msg0=msg8 + "\n" + msg7 + "\n" + msg6 + "\n" + msg5 + "\n" + msg4 + "\n" + msg3 + "\n" + msg2 + "\n\n" + msg;
output.value=msg0;
//for (a=1; a<1000; a++);
if (opti_ind[1].substr(msg8.search(/1/),1) >= 1 &&
opti_ind[2].substr(msg7.search(/1/),1) >= 1 &&
opti_ind[3].substr(msg6.search(/1/),1) >= 1 &&
opti_ind[4].substr(msg5.search(/1/),1) >= 1 &&
opti_ind[5].substr(msg4.search(/1/),1) >= 1 &&
opti_ind[6].substr(msg3.search(/1/),1) >= 1 &&
opti_ind[7].substr(msg2.search(/1/),1) >= 1 ) {
//alert(msg0 + opti_ind[2].substr(msg7.search(/1/),1));
msg_id[1]=msg8.search(/1/)+1;
msg_id[2]=msg7.search(/1/)+1;
msg_id[3]=msg6.search(/1/)+1;
msg_id[4]=msg5.search(/1/)+1;
msg_id[5]=msg4.search(/1/)+1;
msg_id[6]=msg3.search(/1/)+1;
msg_id[7]=msg2.search(/1/)+1;
//alert (msg0);
for (a=1; a<=7; a++){
for (b=1; b<=4; b++){
obj_id=document.getElementById("checkbox"+a+"_"+b);
if (obj_id) obj_id.checked = false;
}
obj_id=document.getElementById("checkbox"+a+"_"+msg_id[a]);
obj_id.checked=true;
}
l++;
define();
//alert(opti_ind[10]);
if (power>opti_ind[10]) {
opti_ind[10]=power;
opti_ind[11]=msg_id[1];
opti_ind[12]=msg_id[2];
opti_ind[13]=msg_id[3];
opti_ind[14]=msg_id[4];
opti_ind[15]=msg_id[5];
opti_ind[16]=msg_id[6];
opti_ind[17]=msg_id[7];
//alert (opti_ind[11]+"\n"+ opti_ind[12]+"\n"+opti_ind[13]+"\n"+opti_ind[14]+"\n"+opti_ind[15]+"\n"+opti_ind[16]+"\n"+opti_ind[17]);
}
}
msg2="";
a=1;
a2++;
}
a2=1;
msg3="";
a3++;
}
a3=1;
msg4="";
a4++;
}
a4=1; msg5="";
a5++;
}
a5=1;
msg6="";
a6++;
}
a6=1;
msg7="";
a7++;
}
a7=1;
msg8="";
a8++;
}
msg0 = msg0 + "\n" + l + "\noptimisation finished";
output.value = msg0;
for (a=1; a<=7; a++){
for (b=1; b<=4; b++){
obj_id=document.getElementById("checkbox"+a+"_"+b);
if (obj_id) obj_id.checked = false;
}
obj_id=document.getElementById("checkbox"+a+"_"+opti_ind[a+10]);
obj_id.checked=true;
}
define();
opt_flag=0;
}
//******* *******
//******* *******
//******* *******
//******* modul engines-dimension *******
//******* *******
//******* *******
//******* *******
var a;
function input(){
var msg_split;
var line;
msg="";
obj=document.getElementById("output2");
msg=obj.value;
msg_split=msg.split("\n");
//alert(msg);
//for (a=0; a<msg_split.length; a++) alert(msg_split[a]);
//alert (msg_split[0].charCodeAt(0));
if (msg_split[0].search("s")!=-1)
{
checkbox1_1.checked = true;
checkbox1_2.checked = false;
sin_vswc.value = msg_split[1]*1000000;
sin_vclc.value = msg_split[2]*1000000;
sin_vswe.value = msg_split[3]*1000000;
sin_vcle.value = msg_split[4]*1000000;
sin_phase.value = msg_split[5]; // /Pi*180;
line=6;
}
if (msg_split[0].search("y")!=-1)
{
checkbox1_2.checked = true;
checkbox1_1.checked = false;
yoke_vclc.value = msg_split[1]*1000000;
yoke_vswc.value = 0;
yoke_vcle.value = msg_split[2]*1000000;
yoke_vswe.value = 0;
yoke_b1.value = msg_split[3]*1000;
yoke_b2.value = msg_split[4]*1000;
yoke_crank.value = msg_split[5]*1000;
yoke_dcomp.value = msg_split[6]*1000;
yoke_dexp.value = msg_split[7]*1000;
line=8;
}
//alert(msg_split[line]);
if (msg_split[line].search("p")!=-1)
{
checkbox2_1.checked=false;
checkbox2_2.checked=true;
checkbox2_3.checked=false;
checkbox2_4.checked=false;
c_pi_din.value = msg_split[line+1]*1000;
c_pi_lk.value = msg_split[line+2]*1000;
c_pi_num.value = msg_split[line+3];
line=line+4;
}
if (msg_split[line].search("a")!=-1)
{
checkbox2_1.checked=false;
checkbox2_2.checked=false;
checkbox2_3.checked=true;
checkbox2_4.checked=false;
c_an_dout.value = msg_split[line+1]*1000;
c_an_din.value = msg_split[line+2]*1000;
c_an_lk.value = msg_split[line+3]*1000;
line=line+4;
}
if (msg_split[line].search("s")!=-1)
{
checkbox2_1.checked=false;
checkbox2_2.checked=false;
checkbox2_3.checked=false;
checkbox2_4.checked=true;
c_sl_w.value = msg_split[line+1]*1000;
c_sl_h.value = msg_split[line+2]*1000;
c_sl_lk.value = msg_split[line+3]*1000;
c_sl_num.value = msg_split[line+4];
line=line+5;
}
//alert(msg_split[line]);
if (msg_split[line].search("d")!=-1)
{
checkbox3_1.checked=false;
checkbox3_2.checked=true;
checkbox3_3.checked=false;
checkbox3_4.checked=false;
r_vol_vr.value = msg_split[line+1]*1000;
line=line+2;
}
if (msg_split[line].search("t")!=-1)
{
checkbox3_1.checked=false;
checkbox3_2.checked=false;
checkbox3_3.checked=true;
checkbox3_4.checked=false;
r_tub_dout.value = msg_split[line+1]*1000;
r_tub_din.value = msg_split[line+2]*1000;
r_tub_lr.value = msg_split[line+3]*1000;
r_tub_num.value = msg_split[line+4];
line=line+5;
}
if (msg_split[line].search("a")!=-1)
{
checkbox3_1.checked=false;
checkbox3_2.checked=false;
checkbox3_3.checked=false;
checkbox3_4.checked=true;
r_an_dout.value = msg_split[line+1]*1000;
r_an_din.value = msg_split[line+2]*1000;
r_an_dimat.value = msg_split[line+3]*1000;
r_an_lr.value = msg_split[line+4]*1000;
line=line+5;
}
//alert(msg_split[line]);
if (msg_split[line].search("m")!=-1)
{
checkbox4_1.checked=false;
checkbox4_2.checked=true;
checkbox4_3.checked=false;
m_mesh_por.value = msg_split[line+1];
m_mesh_dwire.value = msg_split[line+2]*1000;
line=line+3;
}
if (msg_split[line].search("f")!=-1)
{
checkbox4_1.checked=false;
checkbox4_2.checked=false;
checkbox4_3.checked=true;
m_foil_lm.value = msg_split[line+1];
m_foil_th.value = msg_split[line+2]*1000;
line=line+3;
}
if (msg_split[line].search("p")!=-1)
{
checkbox5_1.checked=false;
checkbox5_2.checked=true;
checkbox5_3.checked=false;
checkbox5_4.checked=false;
h_pi_din.value = msg_split[line+1]*1000;
h_pi_lh.value = msg_split[line+2]*1000;
h_pi_num.value = msg_split[line+3];
line=line+4;
}
if (msg_split[line].search("a")!=-1)
{
checkbox5_1.checked=false;
checkbox5_2.checked=false;
checkbox5_3.checked=true;
checkbox5_4.checked=false;
h_an_dout.value = msg_split[line+1]*1000;
h_an_din.value = msg_split[line+2]*1000;
h_an_lh.value = msg_split[line+3]*1000;
line=line+4;
}
if (msg_split[line].search("s")!=-1)
{
checkbox5_1.checked=false;
checkbox5_2.checked=false;
checkbox5_3.checked=false;
checkbox5_4.checked=true;
h_sl_w.value = msg_split[line+1]*1000;
h_sl_h.value = msg_split[line+2]*1000;
h_sl_lh.value = msg_split[line+3]*1000;
h_sl_num.value = msg_split[line+4];
line=line+5;
}
if (msg_split[line].search("h2")!=-1)
{
checkbox6_1.checked=true;
checkbox6_2.checked=false;
checkbox6_3.checked=false;
}
if (msg_split[line].search("he")!=-1)
{
checkbox6_1.checked=false;
checkbox6_2.checked=true;
checkbox6_3.checked=false;
}
if (msg_split[line].search("ai")!=-1)
{
checkbox6_1.checked=false;
checkbox6_2.checked=false;
checkbox6_3.checked=true;
}
checkbox7_1.checked=true;
op_pmean.value = msg_split[line+1]/1000;
op_tk.value = msg_split[line+2];
op_th.value = msg_split[line+3];
op_tr.value =0;
op_freq.value = msg_split[line+4];
}
function input2()
{
msg="";
//msg=msg+"measure_system = '"+measure_system+"';\n\n";
if (checkbox1_1.checked)
{
msg=msg+"s\n";
msg=msg+sin_vswc.value/1000000+"\n";
msg=msg+sin_vclc.value/1000000+"\n";
msg=msg+sin_vswe.value/1000000+"\n";
msg=msg+sin_vcle.value/1000000+"\n";
msg=msg+sin_phase.value+"\n"; // /180*Pi+"\n";
}
if (checkbox1_2.checked)
{
msg=msg+"y\n";
msg=msg+yoke_vclc.value/1000000+"\n";
msg=msg+yoke_vcle.value/1000000+"\n";
msg=msg+yoke_b1.value/1000+"\n";
msg=msg+yoke_b2.value/1000+"\n";
msg=msg+yoke_crank.value/1000+"\n";
msg=msg+yoke_dcomp.value/1000+"\n";
msg=msg+yoke_dexp.value/1000+"\n";
//msg=msg+yoke_vswc.value/1000000+"\n";
//msg=msg+yoke_vswe.value/1000000+"\n";
}
if (checkbox2_1.checked)
{
msg=msg+"sc\n";
//msg=msg+c_smo_a.value+"\n";
//msg=msg+c_smo_lk.value+"\n";
//msg=msg+c_smo_num.value+"\n";
}
if (checkbox2_2.checked)
{
msg=msg+"p\n";
msg=msg+c_pi_din.value/1000+"\n";
msg=msg+c_pi_lk.value/1000+"\n";
msg=msg+c_pi_num.value+"\n";
}
if (checkbox2_3.checked)
{
msg=msg+"a\n";
msg=msg+c_an_dout.value/1000+"\n";
msg=msg+c_an_din.value/1000+"\n";
msg=msg+c_an_lk.value/1000+"\n";
}
if (checkbox2_4.checked)
{
msg=msg+"s\n";
msg=msg+c_sl_w.value/1000+"\n";
msg=msg+c_sl_h.value/1000+"\n";
msg=msg+c_sl_lk.value/1000+"\n";
msg=msg+c_sl_num.value+"\n";
}
if (checkbox3_1.checked)
{
//msg=msg+r_vol_vr.value+"\n";
}
if (checkbox3_2.checked)
{
//msg=msg+r_disp_vr.value+"\n";
}
if (checkbox3_3.checked)
{
msg=msg+"t\n";
msg=msg+r_tub_dout.value/1000+"\n";
msg=msg+r_tub_din.value/1000+"\n";
msg=msg+r_tub_lr.value/1000+"\n";
msg=msg+r_tub_num.value+"\n";
}
if (checkbox3_4.checked)
{
msg=msg+"a\n";
msg=msg+r_an_dout.value/1000+"\n";
msg=msg+r_an_din.value/1000+"\n";
msg=msg+r_an_dimat.value/1000+"\n";
msg=msg+r_an_lr.value/1000+"\n";
}
if (checkbox4_1.checked)
{
//msg=msg+" m_no.value ="+m_no.value+";\n";
}
if (checkbox4_2.checked)
{
msg=msg+"m\n";
msg=msg+m_mesh_por.value+"\n";
msg=msg+m_mesh_dwire.value/1000+"\n";
}
if (checkbox4_3.checked)
{
msg=msg+"f\n";
msg=msg+m_foil_lm.value+"\n";
msg=msg+m_foil_th.value/1000+"\n";
}
if (checkbox5_1.checked)
{
msg=msg+"sc\n";
msg=msg+h_smo_a.value+"\n";
msg=msg+h_smo_lh.value/1000+"\n";
msg=msg+h_smo_num.value+"\n";
}
if (checkbox5_2.checked)
{
msg=msg+"p\n";
msg=msg+h_pi_din.value/1000+"\n";
msg=msg+h_pi_lh.value/1000+"\n";
msg=msg+h_pi_num.value+"\n";
}
if (checkbox5_3.checked)
{
msg=msg+"a\n";
msg=msg+h_an_dout.value/1000+"\n";
msg=msg+h_an_din.value/1000+"\n";
msg=msg+h_an_lh.value/1000+"\n";
}
if (checkbox5_4.checked)
{
msg=msg+"s\n";
msg=msg+h_sl_w.value/1000+"\n";
msg=msg+h_sl_h.value/1000+"\n";
msg=msg+h_sl_lh.value/1000+"\n";
msg=msg+h_sl_num.value+"\n";
}
if (checkbox6_1.checked)
{
msg=msg+"h2\n";
}
if (checkbox6_2.checked)
{
msg=msg+"he\n";
}
if (checkbox6_3.checked)
{
msg=msg+"ai\n";
}
if (checkbox7_1.checked)
{
msg=msg+op_pmean.value*1000+"\n";
msg=msg+op_tk.value+"\n";
msg=msg+op_th.value+"\n";
msg=msg+op_freq.value+"\n";
}
//alert(msg);
obj=document.getElementById("output2");
obj.value=msg;
output2.focus();
output2.select();
window.scrollTo(800,800);
//window.clipboardData.setData('Text', 'text');
window.clipboardData.setData('Text',output2.value);
tempstore=copiedtext;
document.execCommand("Copy");
copiedtext=window.clipboardData.getData();
if (tempstore!=copiedtext) {
alert(copiedtext);}
var therange;
Selection.createTextRange();
alert(therange);
therange.execCommand("Copy");
//output2.execCommand("Copy");
var doc = eval("document.readme."+d);
cp = doc.createTextRange();
//doc.focus();
//doc.select();
cp.execCommand("Copy");
}
// default configuration on start
// HAES GROUP ENGINE
// development values !!!
// Ford 215 hp
measure_system = 'metric';
checkbox1_1.checked = true;
sin_vclc.value =214.2;
sin_vswc.value = 870.6;
sin_vcle.value = 214.2;
sin_vswe.value = 870.6;
sin_phase.value =90;
checkbox1_2.checked = false;
yoke_vclc.value = 0;
yoke_vswc.value = 0;
yoke_vcle.value = 0;
yoke_vswe.value = 0;
yoke_b1.value = 0;
yoke_b2.value = 0;
yoke_crank.value = 0;
yoke_dcomp.value = 0;
yoke_dexp.value = 0;
checkbox1_2.checked = false;
yoke_vclc.value = 8;
yoke_vswc.value = 61;
yoke_vcle.value = 10;
yoke_vswe.value = 61;
yoke_b1.value = 35.4;
yoke_b2.value = 35.4;
yoke_crank.value = 8.5;
yoke_dcomp.value = 56;
yoke_dexp.value = 56;
checkbox2_1.checked=false;
c_smo_a.value = 0;
c_smo_lk.value = 0;
c_smo_num.value = 0;
checkbox2_2.checked= true;
c_pi_din.value = 0.9;
c_pi_lk.value = 87;
c_pi_num.value = 2968;
checkbox2_3.checked= false;
c_an_dout.value = 0;
c_an_din.value = 0;
c_an_lk.value = 0;
checkbox2_4.checked = false;
c_sl_w.value = 0;
c_sl_h.value = 0;
c_sl_lk.value = 0;
c_sl_num.value = 0;
checkbox3_1.checked = false;
r_vol_vr.value = 0;
checkbox3_2.checked = false;
r_disp_vr.value = 0;
checkbox3_3.checked = true;
r_tub_dout.value = 83;
r_tub_din.value = 73;
r_tub_lr.value = 34;
r_tub_num.value = 8;
checkbox3_4.checked = false;
r_an_dout.value = 0;
r_an_din.value = 0;
r_an_dimat.value = 0;
r_an_lr.value = 0;
checkbox4_1.checked=false;
m_no.value =0;
checkbox4_2.checked=true;
m_mesh_por.value = 0.620;
m_mesh_dwire.value = 0.036;
checkbox4_3.checked=false;
m_foil_por.value = 0;
m_foil_lm.value = 0;
m_foil_th.value = 0;
checkbox5_1.checked=false;
h_smo_a.value = 0;
h_smo_lh.value = 0;
h_smo_num.value = 0;
checkbox5_2.checked=true;
h_pi_din.value = 4;
h_pi_lh.value = 462;
h_pi_num.value = 88;
checkbox5_3.checked=false;
h_an_dout.value = 0;
h_an_din.value = 0;
h_an_lh.value = 0;
checkbox5_4.checked=false;
h_sl_w.value = 0;
h_sl_h.value = 0;
h_sl_lh.value = 0;
h_sl_num.value = 0;
checkbox6_1.checked=true;
checkbox6_2.checked=false;
checkbox6_3.checked=false;
checkbox7_1.checked=false;
op_pmean.value = 15000;
op_tk.value = 337;
op_th.value = 1023;
op_tr.value = 0;
op_freq.value = 55;
//default values 2 at startup
//Ross D90
radio1_1.checked=true;
measure_system = 'metric';
checkbox1_1.checked = true;
sin_vclc.value = 8;
sin_vswc.value = 61.05;
sin_vcle.value = 10;
sin_vswe.value = 61.05;
sin_phase.value =95.59;
checkbox1_2.checked = false;
yoke_vclc.value = 8;
yoke_vswc.value = 61;
yoke_vcle.value = 10;
yoke_vswe.value = 61;
yoke_b1.value = 35.4;
yoke_b2.value = 35.4;
yoke_crank.value = 8.5;
yoke_dcomp.value = 55.9;
yoke_dexp.value = 55.9;
checkbox2_1.checked=false;
c_smo_a.value = 0;
c_smo_lk.value = 0;
c_smo_num.value = 0;
checkbox2_2.checked= false;
c_pi_din.value = 0;
c_pi_lk.value = 0;
c_pi_num.value = 0;
checkbox2_3.checked= false;
c_an_dout.value = 0;
c_an_din.value = 0;
c_an_lk.value = 0;
checkbox2_4.checked = true;
c_sl_w.value = 0.532;
c_sl_h.value = 3.15;
c_sl_lk.value = 48;
c_sl_num.value = 388;
checkbox3_1.checked = false;
r_vol_vr.value = 0;
checkbox3_2.checked = false;
r_disp_vr.value = 0;
checkbox3_3.checked = false;
r_tub_dout.value = 0;
r_tub_din.value = 0;
r_tub_lr.value = 0;
r_tub_num.value = 0;
checkbox3_4.checked = true;
r_an_dout.value = 76.2;
r_an_din.value = 73.03;
r_an_dimat.value = 59.44;
r_an_lr.value = 35.18;
checkbox4_1.checked=false;
m_no.value =0;
checkbox4_2.checked=false;
m_mesh_por.value =0;
m_mesh_dwire.value =0;
checkbox4_3.checked=true;
m_foil_por.value =0.7013900972705814;
m_foil_lm.value =6.075;
m_foil_th.value =0.0695;
checkbox5_1.checked=false;
h_smo_a.value =0;
h_smo_lh.value =0;
h_smo_num.value =0;
checkbox5_2.checked=false;
h_pi_din.value =0;
h_pi_lh.value =0;
h_pi_num.value =0;
checkbox5_3.checked=false;
h_an_dout.value =0;
h_an_din.value =0;
h_an_lh.value =0;
checkbox5_4.checked=true;
h_sl_w.value =0.959;
h_sl_h.value =3.556;
h_sl_lh.value =38;
h_sl_num.value =220;
checkbox6_1.checked=false;
checkbox6_2.checked=false;
checkbox6_3.checked=true;
checkbox7_1.checked=true;
op_pmean.value =200;
op_tk.value =300.0;
op_th.value =923.0;
op_freq.value =40.0;
//default values 3 at startup
//first design
/*measure_system = 'metric';
checkbox1_1.checked = true;
sin_vclc.value = 6;
sin_vswc.value = 106;
sin_vcle.value = 6;
sin_vswe.value = 200;
sin_phase.value = 110;
checkbox1_2.checked = false;
yoke_vclc.value = 0;
yoke_vswc.value = 0;
yoke_vcle.value = 0;
yoke_vswe.value = 0;
yoke_b1.value = 0;
yoke_b2.value = 0;
yoke_crank.value = 0;
yoke_dcomp.value = 0;
yoke_dexp.value = 0;
checkbox2_1.checked=false;
c_smo_a.value = 0;
c_smo_lk.value = 0;
c_smo_num.value = 0;
checkbox2_2.checked= false;
c_pi_din.value = 0;
c_pi_lk.value = 0;
c_pi_num.value = 0;
checkbox2_3.checked= true;
c_an_dout.value = 13;
c_an_din.value = 12.5;
c_an_lk.value = 1000;
checkbox2_4.checked = false;
c_sl_w.value = 0;
c_sl_h.value = 0;
c_sl_lk.value = 0;
c_sl_num.value = 0;
checkbox3_1.checked = false;
r_vol_vr.value = 0;
checkbox3_2.checked = false;
r_disp_vr.value = 0;
checkbox3_3.checked = true;
r_tub_dout.value = 16;
r_tub_din.value = 13;
r_tub_lr.value = 50;
r_tub_num.value = 1;
checkbox3_4.checked = false;
r_an_dout.value = 0;
r_an_din.value = 0;
r_an_dimat.value = 0;
r_an_lr.value = 0;
checkbox4_1.checked=false;
m_no.value =0;
checkbox4_2.checked=false;
m_mesh_por.value =0;
m_mesh_dwire.value =0;
checkbox4_3.checked=true;
m_foil_por.value =0.7013900972705814;
m_foil_lm.value =1;
m_foil_th.value =0.1;
checkbox5_1.checked=false;
h_smo_a.value =0;
h_smo_lh.value =0;
h_smo_num.value =0;
checkbox5_2.checked=false;
h_pi_din.value =0;
h_pi_lh.value =0;
h_pi_num.value =0;
checkbox5_3.checked=true;
h_an_dout.value =13;
h_an_din.value =12.5;
h_an_lh.value =1000;
checkbox5_4.checked=false;
h_sl_w.value =0;
h_sl_h.value =0;
h_sl_lh.value =0;
h_sl_num.value = 0;
checkbox6_1.checked=false;
checkbox6_2.checked=false;
checkbox6_3.checked=true;
checkbox7_1.checked=true;
op_pmean.value =100;
op_tk.value =323.0;
op_th.value =523.0;
op_freq.value =8.0;*/
function define(){
// source:
// define the stirling engine geometric
// and operational parameters
// Israel Urieli 4/1/02 (April Fool's Day)
//alert ("define");
//if (window.event.keycode != "13") return;
radio0_2.checked=true;
measure_sys_sub();
/*if (radio1_1.checked==false){
objs = document.getElementById("adiab");
objs.style.visibility = "hidden";
objs = document.getElementById("simple");
objs.style.visibility = "hidden";
}
else {
objs = document.getElementById("adiab");
objs.style.visibility = "visible";
objs = document.getElementById("simple");
objs.style.visibility = "visible";
}*/
/*if (radio1_2.checked==true | radio1_3.checked==true | radio1_4.checked==true){
objs = document.getElementById("td1_2");
objs.style.visibility = "hidden";
checkbox1_1.checked=true;
checkbox1_2.checked=false;
}
else
{
objs = document.getElementById("td1_2");
objs.style.visibility = "visible";
}*/
msg_ges="";
engine();
heatex();
gas();
operat();
}
function engine(){
// source:
// Define engine configuration and drive geometric parameters.
// Israel Urieli 4/14/02
if (checkbox1_1.checked) sin_drive();
if (checkbox1_2.checked) yoke_drive();
}
function sin_drive(){
// source:
// Sinusoidal drive engine configuration
// Israel Urieli 4/14/02
vclc=sin_vclc.value/cm3_inch3;
vswc=sin_vswc.value/cm3_inch3;
vcle=sin_vcle.value/cm3_inch3;
vswe=sin_vswe.value/cm3_inch3;
phase=sin_phase.value;
alpha = sin_phase.value*Pi/180;
msg0 = ("\tvclc " + vclc +
"\nvswc " + vswc +
"\nvcle " + vcle +
"\nvswe " + vswe +
"\nalpha " + Math.round(alpha*1000)/1000 +
"\nphase " + phase );
// alert (msg0);
msg_ges=msg_ges+ "\n\n" +msg0;
}
function yoke_drive(){
// source:
// Ross yoke drive engine configuration
// Israel Urieli 4/14/02
vclc=yoke_vclc.value/cm3_inch3;
vswc=yoke_vswc.value/cm3_inch3;
vcle=yoke_vcle.value/cm3_inch3;
vswe=yoke_vswe.value/cm3_inch3;
dcomp=yoke_dcomp.value/mm1_inch1;
dexp=yoke_dexp.value/mm1_inch1;
b1=yoke_b1.value/mm1_inch1;
b2=yoke_b2.value/mm1_inch1;
crank=yoke_crank.value/mm1_inch1;
acomp=Pi*dcomp*dcomp/4;
aexp=Pi*dexp*dexp/4;
yoke = Math.sqrt(b1*b1 + b2*b2);
ymax = Math.sqrt((yoke + crank)*(yoke + crank) - b2*b2);
ymin = Math.sqrt((yoke - crank)*(yoke - crank) - b2*b2);
vswc = acomp * (ymax - ymin);
vswe = aexp * (ymax - ymin);
//compression piston at bdc(theta_rad):
yc_max_theta_rad=Pi-Math.asin(ymax/(yoke+crank));
//yoke_vswc.value=vswc;
thmaxe = Math.atan((ymax / (yoke + crank)) / Math.sqrt(-(ymax / (yoke + crank))*(ymax / (yoke + crank)) + 1)); //arcsin! Arkussinus(X) = Atn(X / Sqr(-X * X + 1))
thmaxc = Pi - thmaxe;
thmine = Pi + Math.atan((ymin / (yoke - crank)) / Math.sqrt(-(ymin / (yoke - crank))*(ymin / (yoke - crank)) + 1)); //arcsin!
thminc = 3 * Pi - thmine;
alpha = 0.5 * (thmaxc - thmaxe) + 0.5 * (thminc - thmine);
phase = alpha * 180 / Pi;
yoke_vswc.value=Math.round(vswc*cm3_inch3*1000)/1000;
yoke_vswe.value=Math.round(vswe*cm3_inch3*1000)/1000;
msg0 = ("acomp " + Math.round(acomp*1000)/1000 +
"\naexp " + Math.round(aexp*1000)/1000 +
"\nyoke " + Math.round(yoke*1000)/1000 +
"\nymax " + Math.round(ymax*1000)/1000 +
"\nymin " + Math.round(ymin*1000)/1000 +
"\nvswc " + Math.round(vswc*1000000)/1000000 +
"\nvswe " + Math.round(vswe*1000000)/1000000 +
"\nthmaxe " + Math.round(thmaxe*1000)/1000 +
"\nthmaxc " + Math.round(thmaxc*1000)/1000 +
"\nthmine " + Math.round(thmine*1000)/1000 +
"\nthminc " + Math.round(thminc*1000)/1000 +
"\nalpha " + Math.round(alpha*1000)/1000 +
"\nphase " + Math.round(phase*1000)/1000 +
"\nyc_max_theta " + Math.round(yc_max_theta_rad/Pi*180*1000)/1000 );
//alert (msg0);
msg_ges=msg_ges+ "\n\n" +msg0;
}
function heatex(){
// source:
// Specify heat exchanger geometric parameters
// Israel Urieli 3/31/02 (modified 12/01/03)
cooler();
regen();
heater();
}
function cooler(){
// source:
// Specify cooler geometric parameters
// Israel Urieli 4/15/02
if (checkbox2_1.checked){
ak=c_smo_a.value/mm2_inch2;
lk=c_smo_lk.value/mm1_inch1;
numk=c_smo_num.value;
smooth_cyl (numk, ak, lk);
ak=a;
vk=v;
awgk=awg;
}
if (checkbox2_2.checked){
dk=c_pi_din.value/mm1_inch1;
lk=c_pi_lk.value/mm1_inch1;
numk=c_pi_num.value;
pipes (numk, dk, lk);
ak=a;
vk=v;
awgk=awg;
}
if (checkbox2_3.checked){
doutk=c_an_dout.value/mm1_inch1;
dink=c_an_din.value/mm1_inch1;
lk=c_an_lk.value/mm1_inch1;
annulus (doutk, dink, lk);
ak=a;
vk=v;
awgk=awg;
dk=d;
}
if (checkbox2_4.checked){
wk=c_sl_w.value/mm1_inch1;
hk=parseInt(c_sl_h.value*rnds)/rnds/mm1_inch1;
lk=c_sl_lk.value/mm1_inch1;
numk=c_sl_num.value;
slots (wk, hk, numk, lk);
vk=v;
ak=a;
awgk=awg;
dk=d;
}
msg1 = ("Cooler:" +
"\nvoid volume [cm3] " + vk*1000000 +
"\nfree flow area [cm2] " + ak*10000 +
"\nwetted area [cm2] " + awgk*10000 +
"\nhydraulic dia [mm] " + dk*1000 +
"\ncooler length [mm] " + lk*1000);
//alert (msg1);
msg_ges=msg_ges+ "\n\n" +msg1;
}
function heater(){
// source:
// Specify heater geometric parameters
// Israel Urieli 4/15/02
if (checkbox5_1.checked){
ah=h_smo_a.value/mm2_inch2;
lh=h_smo_lh.value/mm1_inch1;
numh=h_smo_num.value;
smooth_cyl (numh , ah, lh);
ah=a;
vh=v;
awgh=awg;
}
if (checkbox5_2.checked){
dh=h_pi_din.value/mm1_inch1;
lh=h_pi_lh.value/mm1_inch1;
numh=h_pi_num.value;
pipes (numh, dh, lh);
ah=a;
vh=v;
awgh=awg;
}
if (checkbox5_3.checked){
douth=h_an_dout.value/mm1_inch1;
dinh=h_an_din.value/mm1_inch1;
lh=h_an_lh.value/mm1_inch1;
annulus (douth, dinh, lh);
ah=a;
vh=v;
awgh=awg;
dh=d;
}
if (checkbox5_4.checked){
wh=h_sl_w.value/mm1_inch1;
hh=parseInt(h_sl_h.value*1000000000)/1000000000/mm1_inch1;
lh=h_sl_lh.value/mm1_inch1;
numh=h_sl_num.value;
slots (wh, hh, numh, lh);
ah=a;
vh=v;
awgh=awg;
dh=d;
}
msg2 = ("Heater:" +
"\nvoid volume [cm3] " + vh*1000000 +
"\nfree flow area [cm2] " + ah*10000 +
"\nwetted area [cm2] " + awgh*10000 +
"\nhydraulic dia [mm] " + dh*1000 +
"\nheater length [mm] " + lh*1000);
//alert (msg2);
msg_ges=msg_ges+ "\n\n" +msg2;
}
function smooth_cyl(num, d, ln){
// only smooth cylinder surface
a=num*Pi*d*d/4;
v=a*ln;
awg=num*Pi*d*ln;
}
function pipes(num, d, ln){
// source:
// homogeneous smooth pipes heat exchanger
// Israel Urieli 4/15/02
a = num*Pi*d*d/4;
v = a*ln;
awg = num*Pi*d*ln;
}
function annulus(dout, din, ln){
// source:
// annular gap heat exchanger
// Israel Urieli 12/01/03
a = Pi*(dout*dout-din*din)/4;
v = a*ln;
awg = Pi*(din + dout)*ln;
d = dout-din;
}
function slots(w, h, num, ln){
// source:
// slots heat exchanger
// Israel Urieli 12/01/03
a = num*w*h;
v = a*ln;
awg = num*2*(w+h)*ln;
d = 4*v/awg;
}
function regen(){
// source:
// Specifies regenerator geometric and thermal properties
// Israel Urieli 04/20/02
if (checkbox3_1.checked){
vr=r_vol_vr.value/cm3_inch3;
amat=0;
awr=0;
lr=0;
gas();
return;
}
if (checkbox3_2.checked){
vr=r_disp_vr.value/cm3_inch3;
gas();
return;
}
if (checkbox3_3.checked){
dout=r_tub_dout.value/mm1_inch1;
din=r_tub_din.value/mm1_inch1;
lr=r_tub_lr.value/mm1_inch1;
num=r_tub_num.value;
dimat=0.0;
}
if (checkbox3_4.checked){
dout=r_an_dout.value/mm1_inch1;
din=r_an_din.value/mm1_inch1;
dimat=r_an_dimat.value/mm1_inch1;
lr=r_an_lr.value/mm1_inch1;
num=1;
}
amat=num*Pi*(din*din-dimat*dimat)/4;
awr=num*Pi*(dout*dout-din*din)/4;
//thermal conductivity [W/m/K]
kwr = 25;
//note that stainless steel thermal conductivity is temp dependent
// 25 W/m/K for normal engine conditions
// 6 W/m/K for cryogenic coolers
// matrix volumetric heat capacity (J/cu.m/K)
// specific heat capacity * density for stainless steel
csm = 3.545e6;
csm = 3545000;
// specific heat capacity * density for copper
// csm = 3.45e6;
// csm = 3450000;
// volumetric heat capacity aluminium
// csm = 2422000;
//regenerator wall thermal conductancd [W/K]
cqwr=kwr*awr/lr;
matrix (amat, lr);
}
function matrix(amat, lr){
// source:
// Specifies regenerator matrix geometric and thermal properties
// Israel Urieli 03/31/02
if (checkbox4_1.checked){
alert ("no matrix");
gas();
}
if (checkbox4_2.checked){
mesh (amat, lr);
}
if (checkbox4_3.checked){
foil (amat, lr);
}
}
function mesh(amat, lr){
// source:
// Specifies mesh matrix geometric and thermal properties
// Israel Urieli 03/31/02
porosity=m_mesh_por.value;
dwire=m_mesh_dwire.value/mm1_inch1;
ar=amat*porosity;
vr=ar*lr;
dr=dwire*porosity/(1-porosity);
awgr=4*vr/dr;
vmetal = (1.0 - porosity)*vr;
if (m_mesh_csm.value>0) csm=m_mesh_csm.value;
cmr = csm*vmetal;
msg3= ("matrix porosity: " + porosity +
"\nmatrix wire diam [mm] " + dwire*1000 +
"\nhydraulic diam [mm] " + dr*1000 +
"\ntotal wetted area [m2] " + awgr +
"\nregenerator length [mm] " + lr*1000 +
"\nvoid volume [cm3] " + vr*1000000 +
"\nmesh thermal capacity J/K " + cmr);
//alert (msg3);
msg_ges=msg_ges+ "\n\n" +msg3;
}
function foil (amat, lr){
// source:
// Specifies foil matrix geometric and thermal properties
// Israel Urieli 03/31/02
fl=m_foil_lm.value/m1_ft1;
th=m_foil_th.value/mm1_inch1;
am=th*fl;
ar=amat-am;
vr=ar*lr;
awgr=2*lr*fl;
dr=4*vr/awgr;
porosity=ar/amat;
m_foil_por.value=porosity;
vmetal = am*lr;
if (m_foil_csm.value>0) csm=m_foil_csm.value;
cmr = csm*vmetal;
msg4= ("unrolled foil lenght [m] " + fl +
"\nfoil thickness [mm] " + th*1000 +
"\nhydraulic diam [mm] " + dr*1000 +
"\nvoid volume [cm3] " + vr*1000000 +
"\ntotal wetted area [m2] " + awgr +
"\nregenerator length [mm] " + lr*1000 +
"\nporosity " + porosity +
"\nfoil thermal capacity J/K " + cmr);
//alert (msg4);
msg_ges=msg_ges+ "\n\n" +msg4;
}
function gas(){
// source:
// specifies the working gas properties (he, h2, air)
// Israel Urieli 4/20/02
if (checkbox6_1.checked){
//hydrogen
gama = 1.4;
rgas = 4157.2;
mu0 = 8.35e-6;
t_suth = 84.4;
}
if (checkbox6_2.checked){
//helium
gama = 1.67;
rgas = 2078.6;
mu0 = 18.85e-6;
t_suth = 80.0;
}
if (checkbox6_3.checked){
//air
gama = 1.4;
rgas = 287.0;
mu0 = 17.08e-6;
t_suth = 112.0;
}
cv=rgas/(gama-1);
cp=gama*cv;
t0=273;
prandtl=0.71;
// (prandtl_air_0°C_1bar-abs=0.7179, prandtl_air_500°C_1bar-abs=0.7194)
// (prandtl_h2o-steam_100°C=0.973, prandtl_h2o-steam_500°C=0.869)
}
function operat(){
// source:
// Determine operating parameters and do Schmidt anlysis
// Israel Urieli 4/20/02
pmean=op_pmean.value*1000; //kPa*1000 metric - inch? N/m² = Pa =
tk=op_tk.value; //K
th=op_th.value;
freq=op_freq.value;
tr=(th-tk)/Math.log(th/tk);
omega=2*Pi*freq;
op_tr.value=Math.round(tr*100)/100;
msg5 = ("operating parameters: " +
"\nmean pressure " + pmean +
"\ncold sink temperature " + tk +
"\nhot sink temperature " + th +
"\neffective reg temp " + tr +
"\noperating freqency " + freq );
//alert (msg5);
msg_ges=msg_ges+ "\n\n" +msg5;
if (radio1_1.checked) schmidt_alpha_urieli();
if (radio1_5.checked) schmidt_gamma_urieli();
if (radio1_2.checked) schmidt_alpha_hirata();
if (radio1_3.checked) schmidt_beta_hirata();
if (radio1_4.checked) schmidt_gamma_hirata();
}
//******* *******
//******* *******
//******* *******
//******* modul schmidt-common code *******
//******* *******
//******* *******
//******* *******
// Schmidt
var vswe;
var vswc;
var alpha;
var th;
var tk;
var vcle;
var vclc;
var vk;
var vr;
var vh;
var tr;
var pmean;
var rgas;
var freq;
var mgas;
var power;
document.writeln("<INPUT type='button' value='Schmidt' onclick=javascript:define() name='calculate' style='position:absolute; left:950; top:40'>");
function schmidt_common()
{
msg6 = ("Schmidt analysis results:" +
"\nWork(joules) " + w + "\nPower(watts) " + power +
"\nQexp(joules) " + we + "\nQcom(joules) " + wc +
"\nindicated efficiency " + eff);
msg_ges=msg_ges + "\n\n" + msg6;
//alert (msg6);
output2.value=msg_ges;
w_schm.value=Math.round(w*1000)/1000;
//obj=document.getElementById("power_schm");
//obj.value=power;
power_schm.value=Math.round(power*1000)/1000;
we_schm.value=Math.round(we*1000)/1000;
wc_schm.value=Math.round(wc*1000)/1000;
eff_schm.value=Math.round(eff*1000)/1000;
//regenerator wall heat leakage [W]
regleak_schm.value = Math.round(cqwr*(th - tk)*1000)/1000;
objs = document.getElementById("table_schm");
objs.style.visibility = "visible";
objs.style.color = "black";
//ReadFiles();
dia_sl_max=0;
if (radio1_1.checked) plotpv_alpha_urieli();
if (radio1_5.checked) plotpv_gamma_urieli();
if (radio1_2.checked) plotpv_alpha_hirata();
if (radio1_3.checked) plotpv_beta_hirata();
if (radio1_4.checked) plotpv_gamma_hirata();
//plot_htm();
plotmass();
}
//******* *******
//******* *******
//******* *******
//******* modul schmidt-alpha-urieli-func *******
//******* *******
//******* *******
//******* *******
// Schmidt
var vswe;
var vswc;
var alpha;
var th;
var tk;
var vcle;
var vclc;
var vk;
var vr;
var vh;
var tr;
var pmean;
var rgas;
var freq;
var mgas;
var power;
document.writeln("<INPUT type='button' value='Schmidt' onclick=javascript:define() name='calculate' style='position:absolute; left:950; top:40'>");
function schmidt_alpha_urieli(){
// source:
// Schmidt anlysis
// Israel Urieli 3/31/02
c = (Math.sqrt((vswe/th)*(vswe/th) + (vswc/tk)*(vswc/tk) + 2*(vswe/th)*(vswc/tk)*Math.cos(alpha)))/2;
s = (vswc/2 + vclc + vk)/tk + vr/tr + (vswe/2 + vcle + vh)/th;
b = c/s;
//if (1-b*b<=0){
//alert (b);
//exit function
//}
sqrtb = Math.sqrt(1 - b*b);
bf = (1 - 1/sqrtb);
beta = Math.atan(vswe*Math.sin(alpha)/th/(vswe*Math.cos(alpha)/th + vswc/tk));
// total mass of working gas in engine
mgas=pmean*s*sqrtb/rgas;
//alert (mgas);
// work output
wc = (Pi*vswc*mgas*rgas*Math.sin(beta)*bf/c);
we = (Pi*vswe*mgas*rgas*Math.sin(beta - alpha)*bf/c);
w = (wc + we);
power = w*freq;
eff = w/we;
//regenerator wall heat leakage [W]
dqwr = Math.round(cqwr*(th - tk)*1000)/1000;
schmidt_common();
}
//******* *******
//******* *******
//******* *******
//******* modul schmidt-gamma-urieli-func *******
//******* *******
//******* *******
//******* *******
// Schmidt
var vswe;
var vswc;
var alpha;
var th;
var tk;
var vcle;
var vclc;
var vk;
var vr;
var vh;
var tr;
var pmean;
var rgas;
var freq;
var mgas;
var power;
document.writeln("<INPUT type='button' value='Schmidt' onclick=javascript:define() name='calculate' style='position:absolute; left:950; top:40'>");
function schmidt_gamma_urieli(){
// source:
// Schmidt anlysis
//
//c = (Math.sqrt((vswe/th)*(vswe/th) + (vswc/tk)*(vswc/tk) + 2*(vswe/th)*(vswc/tk)*Math.cos(alpha)))/2;
c = (Math.sqrt((vswc/tk)*(vswc/tk)-(2*vswc*vswe*Math.cos(alpha)*(tk-th))/(tk*tk*th)+(vswe*vswe*(th-tk)*(th-tk))/(tk*tk*th*th)))/2; //Math.sqrt
s = (vswc/2 + vswe/2 + vclc + vk)/tk + vr/tr + (vswe/2 + vcle + vh)/th;
b = c/s;
//alert("c " + c + " s " + s + " b " + b);
if ((1-b*b)<=0){
//alert (b);
//exit function;
}
sqrtb = Math.sqrt(1 - b*b);
bf = (1 - 1/sqrtb);
//beta = Math.atan(vswe*Math.sin(alpha)/th/(vswe*Math.cos(alpha)/th + vswc/tk));
beta = Math.atan(vswe*Math.sin(alpha)*(th-tk)/(vswe*Math.cos(alpha)*(tk-th) + vswc*th));
//alert (beta);
// total mass of working gas in engine
mgas=pmean*s*sqrtb/rgas;
//alert (mgas);
// work output
wc = (Pi*vswc*mgas*rgas*Math.sin(beta)*bf/c);
we = (Pi*vswe*mgas*rgas*Math.sin(beta - alpha)*bf/c);
w = (wc + we);
power = w*freq;
eff = w/we;
//regenerator wall heat leakage [W]
dqwr = cqwr*(th - tk);
schmidt_common();
}
//******* *******
//******* *******
//******* *******
//******* modul schmidt-alpha-hirata-func *******
//******* *******
//******* *******
//******* *******
// Schmidt
var t;
var v;
var Xde;
var Xdc;
var Xr;
var B;
var S;
var a_;
function schmidt_alpha_hirata(){
// source:
// Koichi Hirata:
// Schmidt theory for stirling engines (.pdf)
t=tk/th;
v=vswc/vswe;
Xde=vcle/vswe;
Xdc=vclc/vswe;
Xr=vr/vswe;
tr=(th+tk)/2;
//mgas=pmean/(rgas*tk)*(t*Ve+(2*pi*Vr)/(1+t)+Vc);
a_=Math.atan(v*Math.sin(alpha)/(t+Math.cos(alpha)));
S=t+2*t*Xde+(4*t*Xr)/(1+t)+v+2*Xdc;
B=Math.sqrt(t*t+2*t*v*Math.cos(alpha)+v*v);
c=B/S;
we=pmean*vswe*Pi*c*Math.sin(a_)/(1+Math.sqrt(1-c*c));
wc=-pmean*vswe*Pi*c*t*Math.sin(a_)/(1+Math.sqrt(1-c*c));
w=we+wc;
power=w*freq;
eff=w/we;
schmidt_common();
}
//******* *******
//******* *******
//******* *******
//******* modul schmidt-beta-hirata-func *******
//******* *******
//******* *******
//******* *******
// Schmidt
var t;
var v;
var vb;
var Xb;
var Xde;
var Xdc;
var Xr;
var B;
var S;
var a_;
function schmidt_beta_hirata(){
// source:
// Koichi Hirata:
// Schmidt theory for stirling engines (.pdf)
t=tk/th;
v=vswc/vswe;
vb = 0.5*(vswe+vswc)-Math.sqrt(0.25*(vswe*vswe+vswc*vswc)-0.5*(vswe*vswc)*Math.cos(alpha));
Xb=vb/vswe;
Xde=vcle/vswe;
Xdc=vclc/vswe;
Xr=vr/vswe;
tr=(th+tk)/2;
//mgas=pmean/(rgas*tk)*(t*Ve+(2*pi*Vr)/(1+t)+Vc);
a_=Math.atan(v*Math.sin(alpha)/(t+Math.cos(alpha)+1));
S=t+2*t*Xde+(4*t*Xr)/(1+t)+v+2*Xdc+1-2*Xb;
B=Math.sqrt(t*t+2*(t-1)*v*Math.cos(alpha)+v*v-2*t+1);
c=B/S;
we=pmean*vswe*Pi*c*Math.sin(a_)/(1+Math.sqrt(1-c*c));
wc=-pmean*vswe*Pi*c*t*Math.sin(a_)/(1+Math.sqrt(1-c*c));
w=we+wc;
power=w*freq;
eff=w/we;
schmidt_common();
}
//******* *******
//******* *******
//******* *******
//******* modul schmidt-gamma-hirata-func *******
//******* *******
//******* *******
//******* *******
function schmidt_gamma_hirata(){
// source:
// Koichi Hirata:
// Schmidt theory for stirling engines (.pdf)
t=tk/th;
v=vswc/vswe;
Xde=vcle/vswe;
Xdc=vclc/vswe;
Xr=vr/vswe;
tr=(th+tk)/2;
//mgas=pmean/rgas*tk*(t*Ve+(2*pi*Vr)/(1+t)+Vc);
a_=Math.atan(v*Math.sin(alpha)/(t+Math.cos(alpha)+1));
S=t+2*t*Xde+(4*t*Xr)/(1+t)+v+2*Xdc+1;
B=Math.sqrt(t*t+2*(t-1)*v*Math.cos(alpha)+v*v-2*t+1);
c=B/S;
we=pmean*vswe*Pi*c*Math.sin(a_)/(1+Math.sqrt(1-c*c));
wc=-pmean*vswe*Pi*c*t*Math.sin(a_)/(1+Math.sqrt(1-c*c));
w=we+wc;
power=w*freq;
eff=w/we;
schmidt_common();
}
//******* *******
//******* *******
//******* *******
//******* modul plotpv_common code*******
//******* *******
//******* *******
//******* *******
var offset;
function plotpv_common()
{
output_values = output_values + "\n";
obj=document.getElementById("output");
obj.value=output_values;
//alert (output_values);
//objFile2.close;
//diagram_line diagram number, position from top, pos from left, diagram height, diagram width, array index for y values, array index for x values, array index for scaling, array name,
// line color, line number, visibilty (visible, hidden), every ... degree (out of 360°), coordinatelines (yes,no), label y_axis, label x_axis,
// 1 measure unit,
if (radio2_1.checked)
{offset=-90;}
else
{offset=0;}
pos_top = 350;
pos_left =20;
dia_height=150;
dia_width=200;
diagram_line (1, 0, 1, var_plot, "black", 1, "visible", theta_step, 360, "v_comp", "degree");
diagram_line (2, 0, 1, var_plot, "gray", 2, "visible", theta_step, 360, "v_exp", "degree");
diagram_line (3, 0, 1, var_plot, "yellow", 3, "visible", theta_step, 360, "v_total", "degree");
ratio_vsw_max_vsw_min.value=Math.round(plot_scl[3][1]/plot_scl[3][2]*1000)/1000;
diagram_line (4, 0, 2, var_plot, "red", 4, "visible", theta_step, 360, "P", "degree");
ratio_p_max_p_min.value=Math.round(plot_scl[4][1]/plot_scl[4][2]*1000)/1000;
diagram (1, pos_top, pos_left, dia_height, dia_width, "yes");
pos_top = 350;
pos_left =450;
dia_height=150;
dia_width=200;
diagram_line (4, 3, 1, var_plot, "black", 1, "visible", theta_step, 360, "P", "v_total");
diagram (2, pos_top, pos_left, dia_height, dia_width, "yes");
}
//******* *******
//******* *******
//******* *******
//******* modul plotpv_alpha_urieli *******
//******* *******
//******* *******
//******* *******
function plotpv_alpha_urieli(){
// plot pv and p-theta diagrams of schmidt analysis
// Israel Urieli 1/6/03
output_values="";
output_values= "theta" + "\t\tcomp v" + "\t\texp v" + "\t\ttotal v" + "\t\tpressure" + "\t\tmgas [gr]" + "\n";
//output.value=output_values;
//objs=getElementById("div_textarea");
//objs.value="output_values;
for (theta = 0; theta<=360; theta=theta+theta_step){
if (checkbox1_1.checked){
theta_rad = theta / 180 * Pi;
vc = vclc + 0.5 * vswc * (1 + Math.cos(theta_rad));
ve = vcle + 0.5 * vswe * (1 + Math.cos(theta_rad + alpha));
}
if (checkbox1_2.checked){
theta_rad = theta / 180 * Pi;
//compression piston at bdc (yc_max_theta_rad):
ymax=Math.sqrt((yoke+crank)*(yoke+crank)-b2*b2);
//yc_max_theta_rad=0;
yc_max_theta_rad=Pi-Math.asin(ymax/(yoke+crank));
sinth = Math.sin(theta_rad+yc_max_theta_rad);
costh = Math.cos(theta_rad+yc_max_theta_rad);
//yc=crank*(sinth-(b2/b1)*costh)+Math.sqrt(b1*b1-crank*crank*costh*costh);
//ye=crank*(sinth+(b2/b1)*costh)+Math.sqrt(b1*b1-crank*crank*costh*costh);
//vc=(yc-ymin)*dcomp*dcomp/4*Pi;
//ve=(ye-ymin)*dexp*dexp/4*Pi;
bth =Math.sqrt (b1*b1 - (crank * costh)*(crank * costh));
ye = crank*(sinth + (b2/b1)*costh) + bth;
yc = crank*(sinth - (b2/b1)*costh) + bth;
ve = vcle + aexp * (ye - ymin);
vc = vclc + acomp * (yc - ymin);
//vc = vclc + 0.5 * vswc * (1 + Math.cos(theta_rad));
//ve = vcle + 0.5 * vswe * (1 + Math.cos(theta_rad + alpha));
}
vtot = (vc + vk + vr + vh + ve);
P = mgas * rgas / (vc / tk + vk / tk + vr / tr + vh / th + ve / th); //Pa;
var_plot [0][theta] = theta;
var_plot [1][theta] = vc*1000000; //cm³
var_plot [2][theta] = ve*1000000;
var_plot [3][theta] = vtot*1000000;
var_plot [4][theta] = P/100000; //bar
var_plot [5][theta] = mgas*1000; //g
output_values = output_values + "\n" + theta + "\t\t" + var_plot [1][theta] + "\t\t" +
var_plot [2][theta] + "\t\t" +
var_plot [3][theta] + "\t\t" +
var_plot [4][theta] + "\t\t" +
var_plot [5][theta] ;
}
plotpv_common();
}
//******* *******
//******* *******
//******* *******
//******* modul plotpv_gamma_urieli *******
//******* *******
//******* *******
//******* *******
function plotpv_gamma_urieli(){
// plot pv and p-theta diagrams of schmidt analysis
// Israel Urieli 1/6/03
output_values="";
output_values= "theta" + "\t\tcomp v" + "\t\texp v" + "\t\ttotal v" + "\t\tpressure" + "\t\tmgas [gr]" + "\n";
//output.value=output_values;
//objs=getElementById("div_textarea");
//objs.value="output_values;
if (checkbox1_1.checked){
for (theta = 0; theta<=360; theta=theta+theta_step){
theta_rad = theta / 180 * Pi;
vc = vclc + 0.5 * vswc * (1 + Math.cos(theta_rad))+ 0.5 * vswe * (1 - Math.cos(theta_rad + alpha));
ve = vcle + 0.5 * vswe * (1 + Math.cos(theta_rad + alpha));
vtot = (vc + vk + vr + vh + ve);
P = mgas * rgas / (vc / tk + vk / tk + vr / tr + vh / th + ve / th); //Pa
var_plot [0][theta] = theta;
var_plot [1][theta] = Math.round(vc*100000000)/100; //cm³
var_plot [2][theta] = Math.round(ve*100000000)/100;
var_plot [3][theta] = Math.round(vtot*100000000)/100;
var_plot [4][theta] = Math.round(P/100)/1000; //bar
var_plot [5][theta] = Math.round(mgas*100000)/100; //gr
output_values = output_values + "\n" + theta + "\t\t" + var_plot [1][theta] + "\t\t" +
var_plot [2][theta] + "\t\t" +
var_plot [3][theta] + "\t\t" +
var_plot [4][theta] + "\t\t" +
var_plot [5][theta] ;
}
}
if (checkbox1_2.checked){
alert ("stirling beta schmidt hirata rossYoke - no formulas");
}
plotpv_common();
}
//******* *******
//******* *******
//******* *******
//******* modul plotpv_alpha_hirata *******
//******* *******
//******* *******
//******* *******
function plotpv_alpha_hirata(){
// plot pv and p-theta diagrams of schmidt analysis
// Israel Urieli 1/6/03
output_values="";
output_values= "theta" + "\t\tcomp v" + "\t\texp v" + "\t\ttotal v" + "\t\tpressure" + "\t\tmgas [gr]" + "\n";
//output.value=output_values;
//objs=getElementById("div_textarea");
//objs.value="output_values;
if (checkbox1_1.checked){
for (theta = 0; theta<=360; theta=theta+theta_step){
theta_rad = (theta+offset) / 180 * Pi;
vc = vclc + 0.5 * vswc * (1 - Math.cos(theta_rad-alpha));
ve = vcle + 0.5 * vswe * (1 - Math.cos(theta_rad));
//not original: cycle start + 90 degree
//vc = vclc + 0.5 * vswc * (1 + Math.cos(theta_rad));
//ve = vcle + 0.5 * vswe * (1 + Math.cos(theta_rad + alpha));
//P=pmean*Math.sqrt(S*S-B*B)/(S-B*Math.sin(theta_rad-a_)); //Pa
vtot = (vc + vk + vr + vh + ve);
P=pmean*Math.sqrt(S*S-B*B)/(S-B*Math.cos(theta_rad-a_)); //Pa
mgas=pmean/(rgas*tk)*(t*ve+2*t*vr/(1+t)+vc);
//mgas=pmean*vswe/(2*rgas*tk)*(s-t*Math.cos(theta_rad)-v*Math.cos(theta_rad-alpha));
//masse = P * (vcle + vswe / 2 * (1 - Cos(theta_rad))) / (rgas * th) * 100000
//massr = P * vr / (rgas * tr) * 100000
//massc = P * (vclc + 0.5 * vswe * (1 + Cos(theta_rad)) + 0.5 * vswc * (1 - Cos(theta_rad - alpha))) / (rgas * tk) * 100000
//mges = masse + massr + massc
mgas_e=P*ve/(rgas*th);
mgas_r=P*vr/(rgas*tr);
mgas_c=P*vc/(rgas*tk);
mgas=mgas_e+mgas_r+mgas_c;
var_plot [0][theta] = theta;
var_plot [1][theta] = vc*1000000; //cm³
var_plot [2][theta] = ve*1000000;
var_plot [3][theta] = vtot*1000000;
var_plot [4][theta] = P/100000; //bar
var_plot [5][theta] = mgas*1000; //g
output_values = output_values + "\n" + theta + "\t\t" + var_plot [1][theta] + "\t\t" +
var_plot [2][theta] + "\t\t" +
var_plot [3][theta] + "\t\t" +
var_plot [4][theta] + "\t\t" +
var_plot [5][theta] ;
}
}
if (checkbox1_2.checked){
alert ("stirling alpha schmidt hirata rossYoke - no formulas");
}
plotpv_common();
}
//******* *******
//******* *******
//******* *******
//******* modul plotpv_beta_hirata *******
//******* *******
//******* *******
//******* *******
function plotpv_beta_hirata(){
// plot pv and p-theta diagrams of schmidt analysis
// Israel Urieli 1/6/03
output_values="";
output_values= "theta" + "\t\tcomp v" + "\t\texp v" + "\t\ttotal v" + "\t\tpressure" + "\t\tmgas [gr]" + "\n";
//output.value=output_values;
//objs=getElementById("div_textarea");
//objs.value="output_values;
if (checkbox1_1.checked){
for (theta = 0; theta<=360; theta=theta+theta_step){
theta_rad = (theta+offset) / 180 * Pi;
vb = 0.5*(vswe+vswc)-Math.sqrt(0.25*(vswe*vswe+vswc*vswc)-0.5*(vswe*vswc)*Math.cos(alpha));
vc = vclc + 0.5*vswe*(1+Math.cos(theta_rad))+0.5 * vswc * (1 - Math.cos(theta_rad-alpha))-vb;
ve = vcle + 0.5 * vswe * (1 - Math.cos(theta_rad));
//not original: cycle start + 90 degree
//vc = vclc + 0.5 * vswc * (1 + Math.cos(theta_rad));
//ve = vcle + 0.5 * vswe * (1 + Math.cos(theta_rad + alpha));
//P=pmean*Math.sqrt(S*S-B*B)/(S-B*Math.sin(theta_rad-a_)); //Pa
vtot = (vc + vk + vr + vh + ve);
P=pmean*Math.sqrt(S*S-B*B)/(S-B*Math.cos(theta_rad-a_)); //Pa
mgas=pmean/(rgas*tk)*(t*ve+2*t*vr/(1+t)+vc);
//mgas=pmean*vswe/(2*rgas*tk)*(s-t*Math.cos(theta_rad)-v*Math.cos(theta_rad-alpha));
//masse = P * (vcle + vswe / 2 * (1 - Cos(theta_rad))) / (rgas * th) * 100000
//massr = P * vr / (rgas * tr) * 100000
//massc = P * (vclc + 0.5 * vswe * (1 + Cos(theta_rad)) + 0.5 * vswc * (1 - Cos(theta_rad - alpha))) / (rgas * tk) * 100000
//mges = masse + massr + massc
mgas_e=P*ve/(rgas*th);
mgas_r=P*vr/(rgas*tr);
mgas_c=P*vc/(rgas*tk);
mgas=mgas_e+mgas_r+mgas_c;
var_plot [0][theta] = theta;
var_plot [1][theta] = vc*1000000; //cm³
var_plot [2][theta] = ve*1000000;
var_plot [3][theta] = vtot*1000000;
var_plot [4][theta] = P/100000; //bar
var_plot [5][theta] = mgas*1000; //g
output_values = output_values + "\n" + theta + "\t\t" + var_plot [1][theta] + "\t\t" +
var_plot [2][theta] + "\t\t" +
var_plot [3][theta] + "\t\t" +
var_plot [4][theta] + "\t\t" +
var_plot [5][theta] ;
}
}
if (checkbox1_2.checked){
alert ("stirling beta schmidt hirata rossYoke - no formulas");
}
plotpv_common();
}
//******* *******
//******* *******
//******* *******
//******* modul plotpv_gamma_hirata *******
//******* *******
//******* *******
//******* *******
function plotpv_gamma_hirata(){
// plot pv and p-theta diagrams of schmidt analysis
// Israel Urieli 1/6/03
//alert ("plot pv");
output_values="";
output_values= "theta" + "\t\tcomp v" + "\t\texp v" + "\t\ttotal v" + "\t\tpressure" + "\t\tmgas" + "\n";
//output.value=output_values;
//objs=getElementById("div_textarea");
//objs.value="output_values;
if (checkbox1_1.checked){
for (theta = 0; theta<=360; theta=theta+theta_step){
theta_rad = (theta+offset) / 180 * Pi;
vc = vclc + 0.5 * vswe * (1 + Math.cos(theta_rad)) + 0.5 * vswc * (1 - Math.cos(theta_rad-alpha));
ve = vcle + 0.5 * vswe * (1 - Math.cos(theta_rad));
//not original: cycle start + 90 degree
//vc = vclc + 0.5 * vswe * (1 + Math.cos(theta_rad)) + 0.5 * vswc * (1 + Math.cos(theta_rad+alpha));
//ve = vcle + 0.5 * vswe * (1 + Math.cos(theta_rad));
//P=pmean*Math.sqrt(S*S-B*B)/(S-B*Math.sin(theta_rad-a_)); //Pa
vtot = (vc + vk + vr + vh + ve);
c=B/S;
P=pmean*Math.sqrt(1-c*c)/(1-c*Math.cos(theta_rad-a_)); //Pa
mgas=P/(rgas*tk)*(t*ve+2*Pi*vr/(1+t)+vc);
mgas_e=P*ve/(rgas*th);
mgas_r=P*vr/(rgas*tr);
mgas_c=P*vc/(rgas*tk);
mgas=mgas_e+mgas_r+mgas_c;
var_plot [0][theta] = theta;
var_plot [1][theta] = vc*1000000; //cm³
var_plot [2][theta] = ve*1000000;
var_plot [3][theta] = vtot*1000000;
var_plot [4][theta] = P/100000; //bar
var_plot [5][theta] = mgas*1000; //g
output_values = output_values + "\n" + theta + "\t\t" + var_plot [1][theta] + "\t\t" +
var_plot [2][theta] + "\t\t" +
var_plot [3][theta] + "\t\t" +
var_plot [4][theta] + "\t\t" +
var_plot [5][theta] ;
}
}
if (checkbox1_2.checked){
alert ("stirling gamma schmidt hirata rossYoke - no formulas");
}
plotpv_common();
}
//******* *******
//******* *******
//******* *******
//******* modul plotmass-func *******
//******* *******
//******* *******
//******* *******
function plotmass(){
// source:
// Kyle Wilson 10-2-02
// ME 589
// Particle Trajectory Map
// Equations from Organ's "'Natural' coordinates for analysis of the practical
// Stirling cycle" and Oegik Soegihardjo's 1993 project on the same topic
NT = th / tk; // Temperature ratio
Vref = vswe; // Reference volume
// Fixed reduced volumes
vswe_r = (vswe / Vref) / NT; // Reduced expansion swept volume (m^3)
vcle_r = (vcle / Vref) / NT; // Reduced expansion clearance volume (m^3)
vh_r = (vh / Vref) / NT; // Reduced heater void volume (m^3)
vr_r = (vr / Vref) * Math.log(NT) / (NT - 1); // Reduced regenerator void volume (m^3)
vk_r = (vk / Vref); // Reduced cooler void volume (m^3)
vswc_r = (vswc / Vref); // Reduced compression swept volume (m^3)
vclc_r = (vclc / Vref); // Reduced compression clearance volume (m^3)
// Volume variations
//Sheets("Plotseite").Cells(2, 10).Value = "Theta"
//Sheets("Plotseite").Cells(2, 11).Value = "Exp vol"
//Sheets("Plotseite").Cells(2, 12).Value = "Comp vol"
//Sheets("Plotseite").Cells(2, 13).Value = "Reduced Exp vol"
//Sheets("Plotseite").Cells(2, 14).Value = "Reduced Comp vol"
//Sheets("Plotseite").Cells(2, 15).Value = "Total vol"
//Sheets("Plotseite").Cells(2, 16).Value = "Reduced vol segments"
step1 = theta_step;
for (theta = 0; theta<=360; theta=theta+theta_step){
theta_rad = theta / 180 * Pi;
deg[theta / step1] = theta; //ang(i) * 180 / Pi;
vep[theta / step1] = (vswe / 2) * (1 - Math.cos(theta_rad)); // Expansion volume vs phase
vcp[theta / step1] = (vswc / 2) * (1 - Math.cos(theta_rad + alpha)); // Compression volume vs phase
vep[theta / step1] = (vep[theta / step1] / Vref) / NT; // Reduced expansion vs phase
vcp[theta / step1] = vcp[theta / step1] / Vref; // Reduced compression vs phase
vtp[theta / step1] = vswe_r + vcle_r + vh_r + vr_r + vk_r + vclc_r + vcp[theta / step1]; // Total volume vs phase
}
/*pos_top=1000;
pos_left=370;
dia_height=150;
dia_width=360;*/
//step2 = 10;
for (m = 1; m<=step2; m++){
for (theta = 0; theta<=360; theta=theta+step1){
vp[theta/step1 ] = vep[theta/step1 ] + (m / step2) * (vtp[theta / step1] - vep[theta / step1]); // Reduced volume segments
var_mass[0][theta/step1/10*theta_step]=theta;
var_mass[m][theta/step1/10*theta_step]= vep[theta/step1 ] + (m / step2) * (vtp[theta / step1] - vep[theta / step1]);
//objFile.WriteLine ("<div style='visibility=visible' id=id" + 10+m + theta + " style='position:absolute; left:" + pos_left+theta + "; top:" + pos_top-round(vp[theta/step1]*200, 0) + "; color:green; font-size:20pt; line-height:20pt; font-family:Verdana; font-weight:normal; '>.</div>")
}
}
pos_top=350;
pos_left=800;
dia_height=150;
dia_width=200;
dia_sl_max=0;
dia_sl_num=0;
//if (dia_sl_num!=0) slide_dia();
slide_dia();
for (m=1; m<=step2; m++) diagram_line (m, 0, 1, var_mass, "black", m, "visible", 1, 36, "", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
// Vertical lines
//L1 = vswe_r // Boundary of reduced expansion swept volume
//L2 = L1 + vcle_r // Boundary of reduced expansion clearance volume
//L3 = L2 + vh_r // Boundary of reduced heater void volume
//L4 = L3 + vr_r // Boundary of reduced regenerator void volume
//L5 = L4 + vk_r // Boundary of reduced cooler void volume
//L6 = Min(vt) // Boundary of reducedexpansion swept volume
//xlabel('Reduced volume')
//ylabel('Crank Angle (deg)')
//title('Particle mass plot')
}
document.writeln("<INPUT type='button' value='adiab' onclick=javascript:adiabatic() name='adiab' style='position:absolute; left:1050; top:950'>");
document.writeln("<INPUT type='button' value='simple' onclick=javascript:simple() name='simple' style='position:absolute; left:1050; top:980'>");
//simple
var twh;
var twk;
var tgh;
var tgk;
var Qkpower;
var Qrpower;
var Qhpower;
var Wpower;
var qrloss;
var dwork;
var qwrl;
var cqwr;
var dwork;
var actWpower;
var actQhpower;
var acteff;
var dwork;
var epsilon2;
// hotsim
var gah = new Array (37);
var t_rey;
var g_rey;
var d_rey;
var ah;
var gh;
var dh;
var remax;
var sumre;
var reavg;
var re = new Array (37);
var omega;
// colsim
var gak = new Array (37);
// reynum
var mu;
var kgas;
var rey;
prandtl=0.71;
// regsim
var gar = new Array (37);
var gr;
var ntu;
var st;
var effect;
var qrmin;
var qrmax;
var qreg = new Array (37);
// pipefr
var fr;
var ht;
// matrixfr
// foilfr
// worksim
var gk;
var re_kol = new Array (37);
var dpkol = new Array (37);
var gr;
var re_reg = new Array (37);
var dpreg = new Array (37);
var gh;
var re_hot = new Array (37);
var dphot = new Array (37);
var dp = new Array (37);
var pcom = new Array (37);
var pexp = new Array (37);
//******* *******
//******* *******
//******* *******
//******* modul adiabatic-simple-func *******
//******* *******
//******* *******
//******* *******
function adiabatic(){
// source:
//[var,dvar] = adiabatic
// ideal adiabatic simulation and temperature/energy vs theta plots
// Israel Urieli, 7/20/2002
// Returned values:
// var(22,37) array of variable values every 10 degrees (0 - 360)
// dvar(16,37) array of derivatives every 10 degrees (0 - 360)
//======================================================================
// do ideal adiabatic analysis:
if (!mgas) define();
//window.scrollTo(500,0);
adiab();
//window.scrollTo(0,0);
// Print out ideal adiabatic analysis results
eff = var_[W_i][COL-1] / var_[QH_i][COL-1]; // engine thermal efficency
qkpower = var_[QK_i][COL-1] * freq; //' Heat transferred to the cooler (W)
qrpower = var_[QR_i][COL-1] * freq; // Heat transferred to the regenerator (W)
qhpower = var_[QH_i][COL-1] * freq; // Heat transferred to the heater (W)
Wpower = var_[W_i][COL-1] * freq; // Total power output (W)
qk_adiab.value=qkpower;
qr_adiab.value=qrpower;
qh_adiab.value=qhpower;
eff_adiab.value=eff;
w_adiab.value=Wpower;
objs = document.getElementById("table_adiab");
objs.style.visibility = "visible";
objs.style.color = "black";
msg8= ("Ideal Adiabatic analysis results" +
"\nHeat transferred to the cooler: " + Math.round(qkpower) + " W" +
"\nNet heat transferred to the regenerator: " + Math.round(qrpower) + " W" +
"\nTotal power output: " + Math.round(Wpower) + " W" +
"\nThermal efficiency: " + Math.round(eff*100));
//alert (msg8);
//objFile.writeLine("</Body>");
//objFile.Close;
// Various plots of the ideal adiabatic simulation results
// plotadiab
dia_sl_max=7;
dia_sl_num=1;
slide_dia();
//window.location.reload()
}
function adiab(){
// source:
// function [var,dvar] = adiab
// ideal adiabatic model simulation
// Israel Urieli, 7/6/2002
// Returned values:
// var(22,37) array of variable values every 10 degrees (0 - 360)
// dvar(16,37) array of derivatives every 10 degrees (0 - 360)
epsilon = 1; //1.0 Allowable error in temerature (K)
max_iteration = 20; // Maximum number of iterations to convergence
ninc = 360; //360; // number if integration increments (every degree)
step3 = ninc / 36; // for saving values in var, dvar matrices
dtheta = 2 * Pi / ninc; // integration increment (radians)
for (i=1; i<=22; i++) {
y[i]=0;
dy[i]=0;
}
output2_values="";
// Initial var and dvar matrix
for (j=0; j<=37; j++) {
for (i=1; i<=30; i++) {
var_[i][j]=0;
dvar[i][j]=0;
}
}
// Initial conditions:
y[THE_i] = th;
y[TCK_i] = tk;
y[TE_i] = th;
y[TC_i] = tk;
iter = 0;
terror = 10 * epsilon; // Initial error to enter the loop
// Iteration loop to cyclic convergence
output2_values=output2_values + "Iteration " + iter + " Tc = " + Math.round(y[TC_i]*100)/100 + " Te = " + Math.round(y[TE_i]*100)/100 +"\n\n";
output2.value=output2_values;
while ((terror >= epsilon) && (iter < max_iteration)){
// cyclic initial conditions
tc0 = y[TC_i];
te0 = y[TE_i];
theta = 0;
y[QK_i] = 0;
y[QR_i] = 0;
y[QH_i] = 0;
y[WC_i] = 0;
y[WE_i] = 0;
y[W_i] = 0;
for (inc=0; inc<ninc; inc=inc+1) {
rk4 (7, theta, dtheta, y);
}
terror = Math.abs(tc0 - y[TC_i]) + Math.abs(te0 - y[TE_i]);
iter++;
output2_values=output2_values + "Iteration " + iter + " Tc = " + Math.round(y[TC_i]*100)/100 + " Te = " + Math.round(y[TE_i]*100)/100 +
"\ntemperatur error ------------- " + Math.round(terror*100)/100 + "\n";
output2.value=output2_values;
}
if (iter >= max_iteration) output2_values="No convergence within " + iter + " iteration ";
output2.value=output2_values;
// a final cycle, to fill the var, dvar matrices
theta = 0;
y[QK_i] = 0;
y[QR_i] = 0;
y[QH_i] = 0;
y[WC_i] = 0;
y[WE_i] = 0;
y[W_i] = 0;
filmatrix (0);
for (j=0; j<=36; j++) var_[0][j]=j*10; //theta_step;
//alert (var_);
y_="";
text = new Array (0,"TC", "TE","QK","QR","QH","WC","WE","W","P","VC","VE","MC","MK","MR","MH","ME","TCK","THE","GACK","GAKR","GARH","GAHE","gAk", "gAr", "gAh");
for (i=1; i<=22; i++) {
y[i]=Math.round(y[i]*1000000)/1000000;
dy[i]=Math.round(dy[i]*1000000)/1000000;
y_=y_+ text[i] + "\t"+ y[i]+ "\t"+ dy[i] + "\n";
}
//alert (y_);
for (i2 = 1; i2<COL; i2++){
for (j = 0; j<step3; j++) rk4(7, theta, dtheta, y);
filmatrix (i2);
}
// calculate gAk, gAr, gAh
// store values in var_[23][j], var_[24][j], var_[25][j]
for (j=0; j<37; j++) {
var_[23][j]=(var_[GACK_i][j] + var_[GAKR_i][j])*omega*1000/2.0; //gak
var_[24][j]=(var_[GAKR_i][j] + var_[GARH_i][j])*omega*1000/2.0; //gar
var_[25][j]=(var_[GARH_i][j] + var_[GAHE_i][j])*omega*1000/2.0; //gah
}
y_="";
text = new Array ("theta","TC", "TE","QK","QR","QH","WC","WE","W","P","VC","VE","MC","MK","MR","MH","ME","TCK","THE","GACK","GAKR","GARH","GAHE", "gAk", "gAr", "gAh");
for (i=0; i<=25; i++) y_=y_ + text[i] + "\t";
y_=y_ + "\n";
for (j=0; j<37; j++) {
//y_=y_+ j*10 + "\t";
for (i=0; i<=25; i++) {
numb=Math.round(var_[i][j]*1000000)/1000000;
numb2=numb.toString();
numb=numb2.replace(".",",");
y_=y_+ numb + "\t";
}
y_=y_+"\n";
}
output_values=y_;
output.value=output_values;
}
function euler(n,x,dx, y)
{
x0 = x;
dytemp=dadiab(x0, y);
for (i=0; i<=22; i++) dy[i]=dytemp[i];
for(i = 0; i < n; i++) y[i] = parseFloat(y[i]) + dx * parseFloat(dy[i]);
x1 = x0 + dx;
theta = x1;
}
function rk4 (n, x, dx, y){
//alert ("rk4");
//rk4("dadiab", 7, theta, dtheta, y)
//function (x, y, dy) = rk4(deriv,n,x,dx,y)
//Classical fourth order Runge-Kutta method
//Integrates n first order differential equations
//dy(x,y) over interval x to x+dx
//Israel Urieli - Jan 21, 2002
x0 = x;
//y0 = y;
for (i=0; i<=22; i++) y0[i]=y[i];
dytemp=dadiab(x0, y);
for (i=0; i<=22; i++) dy1[i]=dytemp[i];
//[y,dy1] = feval("dadiab", x0, y)
for (i = 0; i<=n; i++) y[i] = parseFloat(y0[i]) + 0.5 * dx * parseFloat(dy1[i]);
xm = x0 + 0.5 * dx;
//theta=x0 + 0.5 * dx;
dytemp=dadiab(xm, y);
for (i=0; i<=22; i++) dy2[i]=dytemp[i];
//[y,dy2] = feval("dadiab", xm, y)
for (i = 0; i<=n; i++) y[i] = parseFloat(y0[i]) + 0.5 * dx * parseFloat(dy2[i]);
dytemp=dadiab(xm, y);
for (i=0; i<=22; i++) dy3[i]=dytemp[i];
//[y,dy3] = feval("dadiab", xm, y)
for (i = 0; i<=n; i++) y[i] = parseFloat(y0[i]) + dx * parseFloat(dy3[i]);
x1 = x0 + dx;
//theta=x0 + dx;
dytemp=dadiab(x, y);
for (i=0; i<=22; i++) dy4[i]=dytemp[i];
//[y,dy] = feval("dadiab", x, y)
for (i = 0; i<=n; i++) {
dy[i] = (parseFloat(dy1[i]) + 2 * (parseFloat(dy2[i]) + parseFloat(dy3[i])) + parseFloat(dy4[i])) / 6;
y[i] = parseFloat(y0[i]) + dx * parseFloat(dy[i]);
}
x=x1;
theta = x1;
y_="";
text = new Array (0,"TC", "TE","QK","QR","QH","WC","WE","W","P","VC","VE","MC","MK","MR","MH","ME","TCK","THE","GACK","GAKR","GARH","GAHE");
for (i=1; i<=22; i++) {
y_=y_+ text[i] + "\t"+ + Math.round(y[i]*1000000)/1000000+ "\t"+ Math.round(dy[i]*1000000)/1000000 + "\t" + Math.round(dy1[i]*1000000)/1000000+ "\t"+ Math.round(dy2[i]*1000000)/1000000+ "\t"+ Math.round(dy3[i]*1000000)/1000000+ "\n";
}
//alert (inc + "\n" + "\t" + "y" + "\t" + "dy" + "\t" + "dy1" + "\t" + "dy2" + "\t" + "dy3" + "\n" + y_);
//alert (x);
//if (inc==36)window.location.reload();
}
function dadiab(theta, y){
//function [y,dy] = dadiab(theta,y)
// Evaluate ideal adiabatic model derivatives
// Israel Urieli, 7/6/2002
// Arguments: theta - current cycle angle [radians]
// y(22) - vector of current variable values
// Returned values:
// y(22) - updated vector of current variables
// dy(16) vector of current derivatives
// Function invoked : volume.m
// Volume and volume derivatives:
volume (theta);
y[VC_i] = vc;
y[VE_i] = ve;
dy[VC_i] = dvc;
dy[VE_i] = dve;
//alert (dve + ".." + inc);
// Pressure and pressure derivatives:
vot = vk / tk + vr / tr + vh / th;
y[P_i] = (mgas * rgas / (y[VC_i] / y[TC_i] + vot + y[VE_i] / y[TE_i]));
Top = -y[P_i] * (dy[VC_i] / y[TCK_i] + dy[VE_i] / y[THE_i]);
bottom = (y[VC_i] / (y[TCK_i] * gama) + vot + y[VE_i] / (y[THE_i] * gama));
dy[P_i] = Top / bottom;
// Mass accumulations and derivatives:
y[MC_i] = y[P_i] * y[VC_i] / (rgas * y[TC_i]);
y[MK_i] = y[P_i] * vk / (rgas * tk);
y[MR_i] = y[P_i] * vr / (rgas * tr);
y[MH_i] = y[P_i] * vh / (rgas * th);
y[ME_i] = y[P_i] * y[VE_i] / (rgas * y[TE_i]);
dy[MC_i] = (y[P_i] * dy[VC_i] + y[VC_i] * dy[P_i] / gama) / (rgas * y[TCK_i]);
dy[ME_i] = (y[P_i] * dy[VE_i] + y[VE_i] * dy[P_i] / gama) / (rgas * y[THE_i]);
dpop = dy[P_i] / y[P_i];
dy[MK_i] = y[MK_i] * dpop;
dy[MR_i] = y[MR_i] * dpop;
dy[MH_i] = y[MH_i] * dpop;
// Mass flow between cells:
y[GACK_i] = -dy[MC_i];
y[GAKR_i] = y[GACK_i] - dy[MK_i];
y[GAHE_i] = dy[ME_i];
y[GARH_i] = y[GAHE_i] + dy[MH_i];
// Conditional temperatures between cells:
y[TCK_i] = tk;
if (y[GACK_i] > 0) y[TCK_i] = y[TC_i];
y[THE_i] = y[TE_i];
if (y[GAHE_i] > 0) y[THE_i] = th;
// 7 derivatives to be integrated by rk4:
// Working space temperatures:
dy[TC_i] = y[TC_i] * (dpop + dy[VC_i] / y[VC_i] - dy[MC_i] / y[MC_i]);
dy[TE_i] = y[TE_i] * (dpop + dy[VE_i] / y[VE_i] - dy[ME_i] / y[ME_i]);
// Energy:
dy[QK_i] = vk * dy[P_i] * cv / rgas - cp * (y[TCK_i] * y[GACK_i] - tk * y[GAKR_i]);
dy[QR_i] = vr * dy[P_i] * cv / rgas - cp * (tk * y[GAKR_i] - th * y[GARH_i]);
dy[QH_i] = vh * dy[P_i] * cv / rgas - cp * (th * y[GARH_i] - y[THE_i] * y[GAHE_i]);
dy[WC_i] = y[P_i] * dy[VC_i];
dy[WE_i] = y[P_i] * dy[VE_i];
// Net work done:
dy[W_i] = dy[WC_i] + dy[WE_i];
y[W_i] = y[WC_i] + y[WE_i];
//
y_="";
text = new Array (0,"TC", "TE","QK","QR","QH","WC","WE","W","P","VC","VE","MC","MK","MR","MH","ME","TCK","THE","GACK","GAKR","GARH","GAHE");
for (i=1; i<=22; i++) {
y_=y_+ text[i] + "\t"+ y[i]+ "\t"+ dy[i] + "\n";
}
output_values=y_;
output.value=output_values
//alert (y_);
return dy;
}
function volume(theta){
// determine working space volume variations and derivatives
// Israel Urieli, 7/6/2002
// Argument: theta - current cycle angle [radians]
// Returned values:
// vc, ve - compression, expansion space volumes [m^3]
// dvc, dve - compression, expansion space volume derivatives
if (checkbox1_1.checked) sinevol (theta);
if (checkbox1_2.checked) yokevol (theta);
}
function sinevol(theta){
// sinusoidal drive volume variations and derivatives
// Israel Urieli, 7/6/2002
// Argument: theta - current cycle angle [radians]
// Returned values:
// vc, ve - compression, expansion space volumes [m^3]
// dvc, dve - compression, expansion space volume derivatives
// alpha urieli
if (radio1_1.checked) {
vc = vclc + 0.5 * vswc * (1 + Math.cos(theta));
ve = vcle + 0.5 * vswe * (1 + Math.cos(theta + alpha));
dvc = -0.5 * vswc * Math.sin(theta);
dve = -0.5 * vswe * Math.sin(theta + alpha);
}
// alpha, beta, gamma hirata?
if (radio1_5.checked) {
vc = vclc + 0.5 * vswc * (1 + Math.cos(theta)) + 0.5 * vswe * (1 - Math.cos(theta+ alpha));
ve = vcle + 0.5 * vswe * (1 + Math.cos(theta + alpha));
dvc = -0.5*vswc*Math.sin(theta)+0.5*vswe*Math.sin(theta+alpha);
dve = -0.5*vswe*Math.sin(theta+alpha);
}
if (radio1_3.checked) {
//vb = 0.5*(vswe+vswc)-Math.sqrt(0.25*(vswe*vswe+vswc*vswc)-0.5*(vswe*vswc)*Math.cos(alpha));
//vc = vclc + 0.5*vswe*(1+Math.cos(theta_rad))+0.5 * vswc * (1 - Math.cos(theta_rad-alpha))-vb;
vc = vclc + 0.5*vswe*(1+Math.cos(theta_rad))+0.5 * vswc * (1 - Math.cos(theta_rad-alpha))-0.5*(vswe+vswc)-Math.sqrt(0.25*(vswe*vswe+vswc*vswc)-0.5*(vswe*vswc)*Math.cos(alpha));
ve = vcle + 0.5 * vswe * (1 - Math.cos(theta_rad));
dvc=0.5*vswc*Math.sin(theta_rad-alpha)-0.5*vswe*Math.sin(theta_rad);
dve=0.5*vswe*Math.sin(theta_rad);
}
if (radio1_4.checked) {
vc = vclc + 0.5 * vswe * (1 - Math.cos(theta)) + 0.5 * vswc * (1 - Math.cos(theta-alpha));
ve = vcle + 0.5 * vswe * (1 - Math.cos(theta));
dvc = 0.5*vswe*Math.sin(theta)+0.5*vswc*Math.sin(theta-alpha);
dve = 0.5*vswe*Math.sin(theta);
}
}
function yokevol(theta){
// Ross yoke drive volume variations and derivatives
// Israel Urieli, 7/6/2002
// Argument: theta - current cycle angle [radians]
// Returned values:
// vc, ve - compression, expansion space volumes [m^3]
// dvc, dve - compression, expansion space volume derivatives
sinth = Math.sin(theta);
costh = Math.cos(theta);
bth =Math.sqrt (b1*b1 - (crank * costh)*(crank * costh));
ye = crank*(sinth + (b2/b1)*costh) + bth;
yc = crank*(sinth - (b2/b1)*costh) + bth;
ve = vcle + aexp * (ye - ymin);
vc = vclc + acomp * (yc - ymin);
dvc = acomp*crank*(costh + (b2/b1) * sinth + crank*sinth*costh/bth);
dve = aexp*crank*(costh - (b2/b1) * sinth + crank*sinth*costh/bth);
// alpha, beta, gamma hirata?
}
function filmatrix(j){
// [var,dvar]=Filmatrix(j,y,dy,var,dvar)
// Fill in the j-th column of the var, dvar matrices with values of y, dy
// Israel Urieli, 7/20/2002
// Arguments: j - column index (1 - 37, every 10 degrees of cycle angle)
// y(ROWV) - vector of current variable values
// dy(ROWD) vector of current derivatives
// var(ROWV,37) - matrix of current variables vs cycle angle
// dvar(ROWD,37) - matrix of current derivatives vs cycle angle
// Returned values:
// var(ROWV,37) - matrix of updated variables vs cycle angle
// dvar(ROWD,37) - matrix of updated derivatives vs cycle angle
ROWV = 22; // number of rows in the var matrix
ROWD = 16; // number of rows in the dvar matrix
for (i = 1; i<=ROWV; i++) {
var_[i][j] = y[i];
//if (i==9) var_[i][j]= Math.round(y0[i]*100)/10000000;
//if (i==14) alert (y[MR_i]);
}
for (i = 1; i<=ROWD; i++) dvar[i][j] = dy[i];
}
//*************************************************************************************************************************************
//*************************************************************************************************************************************
//*************************************************************************************************************************************
//*************************************************************************************************************************************
//*************************************************************************************************************************************
function simple() {
//function [var,dvar]=simple
//simple analysis - including heat transfer and pressure drop effects
//Israel Urieli, 7/22/2002 (modified 12/3/2003 for temp plots)
//Returned values:
// var(22,37) array of variable values every 10 degrees (0-360)
// dvar(16,37) array of derivatives every 10 degrees (0-360)
if (!mgas) define();
output3.value="";
twk=tk; //Cooler wall temp - equal to initial cooler gas temp
twh=th; //Heater wall temp - equal to initial heater gas temp
epsilon2=1; //allowable temperature error bound for cyclic convergence
terror=10*epsilon2; //Initial temperature error (to enter loop)
while (terror > epsilon2) {
//output3.value="";
adiab();
hotsim(twh); //new heater gas temperature
kolsim(twk); //new cooler gas temperature
terror=(th-tgh)+(tk-tgk);
//alert(terror);
if (terror<epsilon2) break;
th=tgh;
tk=tgk;
tr=(th-tk)/Math.log(th/tk);
}
eff = Math.round(var_[W_i][COL-1]/var_[QH_i][COL-1]*1000)/1000;
cop = Math.round(var_[QH_i][COL-1]/var_[W_i][COL-1]*1000)/1000;
output3.value = output3.value + "\nHeat Exchanger analysis converged..." +
"\nIdeal Adiabatic output: Th = " + Math.round (th*1000)/1000 + " Tk = " + Math.round (tk*1000)/1000 +
"\nQk [W] = " + Math.round (var_[QK_i][COL-1]*freq*1000)/1000 + " Qr [W] = " + Math.round(var_[QR_i][COL-1]*freq*1000)/1000 +
" Qh [W] = " + Math.round(var_[QH_i][COL-1]*freq*1000)/1000 +
"\nWc [W] = " + Math.round(var_[WC_i][COL-1]*freq*1000)/1000 + " We [W] = " + Math.round(var_[WE_i][COL-1]*freq*1000)/1000 +
" W [W] = " + Math.round(var_[W_i][COL-1]*freq*1000)/1000 +
"\neff (W/Qh) = " + eff + " COP (Qh/W) = " + cop +
"\n\nRegenerator simple analysis..." +
"\nideal heat accepted [W] " + Math.round(var_[QH_i][36]*freq*1000)/1000 +
"\nideal indicated power [W] " + Math.round(var_[W_i][36]*freq*1000)/1000;
regsim();
if(th < tk) qrloss = -qrloss; /* if refrigerator... */
qwrl=cqwr*(twh-twk)/freq;
output3.value = output3.value + "\nRegenerator net enthalpy loss [W] " + Math.round (qrloss*freq*1000)/1000 +
"\nRegenerator wall heat leakage [W] " + Math.round (qwrl*freq*1000)/1000 ;
worksim();
//actWpower=Wpower-dwork*freq;
//actQhpower=Qhpower+qrloss*freq+qwrl*freq;
//acteff=actWpower/actQhpower;
output3.value = output3.value + "\npressure drop available work loss [W] " + dwork*freq ;
/***Appendix gap losses - relevant if displacer or hot piston data available */
/* aploss(var,shutls,enthls,sealls)
printf(" shuttle loss (Watts) %.3f\n", shutls);
printf(" gap entalpy (pumping) loss (Watts) %.3f\n", enthls);
printf(" displacer seal PV loss (Watts) %.3f\n", sealls);
fprintf(printfile," shuttle loss (Watts) %.3f\n", shutls);
fprintf(printfile," gap entalpy (pumping) loss (Watts) %.3f\n", enthls);
fprintf(printfile," displacer seal PV loss (Watts) %.3f\n", sealls); */
dia_sl_max=11;
dia_sl_num=1;
slide_dia();
//plotadiab;
qk_simple.value=Math.round (var_[QK_i][COL-1]*freq*1000)/1000;
qr_simple.value=Math.round(var_[QR_i][COL-1]*freq*1000)/1000;
qh_simple.value=Math.round(var_[QH_i][COL-1]*freq*1000)/1000;
eff_simple.value=eff;
w_simple.value=Math.round(var_[W_i][COL-1]*freq*1000)/1000;
objs = document.getElementById("table_simple");
objs.style.visibility = "visible";
objs.style.color = "black";
}
function hotsim(twh) {
// function tgh=hotsim(var,twh)
// evaluate heater average heat transfer performance
// Israel Urieli, 7/22/2002
//Arguments:
// var(22,37) array of variable values every 10 degrees (0-360)
// twh - heater wall temperature [K]
// Returned values:
// tgh - heater average gas temperature [K]
// Calculating the Reynolds number over the cycle
for (a=0; a<37;a++){
gah[a]=(var_[GARH_i][a]+var_[GAHE_i][a])*omega/2;
gh=gah[a]/ah;
t_rey=th;
g_rey=gh;
d_rey=dh;
reynum();
re[a]=rey;
var_[REYHOT][a]=rey;
}
sumre=0;
remax=re[0];
for (a=0; a<36; a++){
sumre=sumre + re[a];
if (re[a]>remax) remax=re[a];
}
reavg=sumre/36;
pipefr(reavg); //Heat transfer coefficient
tgh=twh - var_[QH_i][36]*freq/(ht*awgh); //Heater gas temperature [K]
//hotsim=tgh;
msg_simple2= "Heater Average Reynolds number ... " + Math.round (reavg*1000)/1000 +
"\nHeater maximum Reynolds number " + Math.round (remax*1000)/1000 +
"\nHeater heat transfer coefficient (W/m2*K) " + Math.round (ht*1000)/1000 +
"\nHeater wall temp " + Math.round (twh*1000)/1000 +
"\nHeater gas temp " + Math.round (tgh*1000)/1000 + "\n";
//alert ("msg_simple2" " + "\n" + msg_simple2);
output3.value =output3.value + msg_simple2;
}
function kolsim(twk){
// function tgk=kolsim(var,twk)
// evaluate cooler average heat transfer performance
// Israel Urieli, 7/22/2002
//Arguments:
// var(22,37) array of variable values every 10 degrees (0-360)
// twk - cooler wall temperture [K]
// Returned values:
// tgk - cooler average gas temperature [K]
// Calculating the Reynolds number over the cycle
for (a=0; a<37;a++){
gak[a]=(var_[GACK_i][a]+var_[GAKR_i][a])*omega/2;
gk=gak[a]/ak;
t_rey=tk;
g_rey=gk;
d_rey=dk;
reynum();
re[a]=rey;
var_[REYKOL][a]=rey;
}
//Average and maximum Reynolds number
sumre=0;
remax=re[0];
for (a=0; a<36; a++){
sumre=sumre + re[a];
if (re[a]>remax) remax=re[a];
}
reavg=sumre/36;
pipefr(reavg); //Heat transfer coefficient
tgk=twk - var_[QK_i][36]*freq/(ht*awgk); //Cooler gas temperature [K]
//kolsim=tgk;
msg_simple3= "Cooler Average Reynolds number ..." + Math.round (reavg*1000)/1000 +
"\nCooler maximum Reynolds number " + Math.round (remax*1000)/1000 +
"\nCooler heat transfer coefficient (W/m2*K) " + Math.round (ht*1000)/1000 +
"\nCooler wall temp " + Math.round (twk*1000)/1000 +
"\nCooler gas temp " + Math.round (tgk*1000)/1000 + "\n";
//alert ("msg_simple3" + "\n" + msg_simple3);
output3.value = output3.value+msg_simple3;
}
function reynum() {
//function [mu,kgas,re] = reynum(t,g,d)
// evaluate dynamic viscosity, thermal conductivity, Reynolds number
// Israel Urieli, 7/22/2002
// Arguments:
// t_rey - gas temperature [K]
// g_rey - mass flux [kg/m^2.s]
// d_rey - hydraulic diameter [m]
// Returned values:
// mu - gas dynamic viscosity [kg.m/s]
// kgas - gas thermal conductivity [W/m.K]
// re - Reynolds number
mu=mu0*(t0+t_suth)/(parseFloat(t_rey)+t_suth)*Math.pow((t_rey/t0),1.5);
//alert (" mu " + mu + " t_rey " + t_rey + " t0 + t_suth " + (t0+t_suth) + " t_rey+t_suth " + (t_rey+t_suth) + " Math.pow((t_rey/t0),1.5) " + (Math.pow((t_rey/t0),1.5)));
kgas=cp*mu/prandtl;
if (g_rey<0) g_rey=-g_rey;
rey=g_rey*d_rey/mu;
//rey=Math.abs(g_rey)*d_rey/mu;
if (rey<1) rey=1;
}
function regsim() {
//function qrloss = regsim(var)
// Evaluate the effectiveness and performance of the regenerator
// Israel Urieli, 7/23/2002
// Arguments:
// var(22,37) array of variable values every 10 degrees (0 - 360)
// Returned value:
// qrloss - regenerator net enthalpy loss [J]
// Reynolds number over the cycle
for (a = 0; a<37; a++) {
gar[a] = (var_[GAKR_i][a] + var_[GARH_i][a]) * omega / 2;
gr = gar[a] / ar;
t_rey = tr;
g_rey = gr;
d_rey = dr;
reynum();
re[a] = rey;
var_[REYREG][a]=rey;
}
// average and maximum Reynolds number
sumre = 0;
remax = re[0];
for (a=0; a<36; a++){
sumre = sumre + re[a];
if (re[a] > remax) remax = re[a];
}
reavg = sumre / 36;
// Stanton number, number of transfer units, regenerator effectiveness
if (document.getElementById("checkbox4_2").checked) matrixfr(reavg);
if (document.getElementById("checkbox4_3").checked) foilfr(reavg);
ntu = st * awgr / (2 * ar);
effect = ntu / (ntu + 1);
// Calculate qrloss
qrmin = var_[QR_i][1];
qrmax = var_[QR_i][1];
for (i = 0;i<37; i++) {
qreg[i] = var_[QR_i][i];
if (qrmin >= qreg[i]) qrmin = qreg[i];
if (qrmax <= qreg[i]) qrmax = qreg[i];
}
qrloss = (1 - effect) * (qrmax - qrmin);
//regsim = qrloss;
msg_simple4="\nRegenerator Average Reynolds number ... " + Math.round (reavg*1000)/1000 +
"\nRegenerator maximum Reynolds number " + Math.round (remax*1000)/1000 +
"\nRegenerator Stanton number (Average Re) " + Math.round (st*1000)/1000 +
"\nRegenerator Number of transfer units " + Math.round (ntu*1000)/1000 +
"\nRegenerator effectiveness " + Math.round (effect*1000)/1000 +
"\nRegenerator Qrloss (J) " + Math.round (qrloss*1000)/1000 + "\n";
//alert ("msg_simple4 " + msg_simple4);
output3.value = output3.value + msg_simple4;
}
function pipefr(re) {
//function [ht,fr]=Pipe_fr(d,mu,re)
// evaluate heat transfer coefficient, Reynolds friction factor
// Israel Urieli, 7/22/2002
// Arguments:
// d - hydraulic diameter [m]
// mu - gas dynamic viscosity [kg.m/s]
// re - Reynolds number
// Returned values:
// ht - heat transfer coefficient [W/m^2.K]
// fr - Reynolds friction factor ( = re*fanning friction factor)
var re;
// Personal communication with Alan Organ, because of oscillating
// flow, we assume that flow is always turbulent. Use the Blasius
// relation for all Reynolds numbers:
fr = 0.0791*Math.pow(re,0.75);
// From Reynolds simple analogy:
ht = fr * mu * cp / (2 * d_rey * prandtl);
//alert ("fr " + fr + " mu " + mu + " cp " + cp + " d_rey " + d_rey + " prandtl " + prandtl + " rey " + rey);
//haes stim.zip
if(re < 2000.0) fr = 16.0;
if((re > 2000.0)&&(re < 4000.0)) fr = 7.3439e-4*Math.pow(re,1.3142);
if(re >= 4000.0) fr = 0.0791*Math.pow(re,0.75);
ht = fr*mu*cp/(2.0*d_rey*prandtl);
}
function matrixfr(re) {
//function [st,fr] = matrixfr(re)
// evaluate regenerator mesh matrix stanton number, friction factor
// Israel Urieli, 7/22/2002
// Arguments:
// rey - Reynolds number
// Returned values:
// st - Stanton number
// fr - Reynolds friction factor ( = re*fanning friction factor)
var re;
// equations taken from Kays & London (1955 edition)
st = 0.46* Math.pow(re,(-0.4)) / prandtl;
fr = 54 + 1.43*Math.pow(re, 0.78);
}
function foilfr(re) {
// evaluate regenerator wrapped foil stanton number, friction factor
// Israel Urieli, 7/22/2002
// Arguments:
// d - hydraulic diameter [m]
// mu - gas dynamic viscosity [kg.m/s]
// rey - Reynolds number
// Returned values:
// st - Stanton number
// ht - heat transfer coefficient [W/m^2.K]
// fr - Reynolds friction factor ( = re*fanning friction factor)
var re;
if (re < 2000) fr=24; // normally laminar flow
if (re>=2000) fr=0.0791* Math.pow(re,0.75);
// From Reynolds simple analogy:
st = fr / (2 * re * prandtl);
ht = st * re * cp * mu / d_rey;
ht = fr/(2*prandtl)*cp*mu/d_rey;
}
function worksim() {
//function dwork = worksim(var,dvar)
// Evaluate the pressure drop available work loss [J]
// Israel Urieli, 7/23/2002
// Arguments:
// var(22,37) array of variable values every 10 degrees (0 - 360)
// dvar(16,37) array of derivatives every 10 degrees (0 - 360)
// Returned value:
// dwork - pressure drop available work loss [J]
dtheta = 2 * Pi / 36;
dwork = 0; // initialise pumping work loss
msg_simple5 = "";
for (i = 0; i<36; i++) {
gk = (var_[GACK_i][i] + var_[GAKR_i][i]) * omega / (2 * ak);
t_rey = tk;
g_rey = gk;
d_rey = dk;
reynum();
re_kol[i] = rey;
pipefr(rey);
dpkol[i] = 2 * fr * mu * vk * gk * lk / (var_[MK_i][ i] * dk*dk);
gr = (var_[GAKR_i][i] + var_[GARH_i][i]) * omega / (2 * ar);
t_rey = tr;
g_rey = gr;
d_rey = dr;
reynum();
re_reg[i] = rey;
if (document.getElementById("checkbox4_2").checked) matrixfr(rey);
if (document.getElementById("checkbox4_3").checked) foilfr(rey);
dpreg[i] = 2 * fr * mu * vr * gr * lr / (var_[MR_i][i] * dr * dr);
gh = (var_[GARH_i][i] + var_[GAHE_i][i]) * omega / (2 * ah);
t_rey = th;
g_rey = gh;
d_rey = dh;
reynum();
re_hot[i] = rey;
pipefr(rey);
dphot[i] = 2 * fr * mu * vh * gh * lh / (var_[MH_i][i] * dh * dh);
dp[i] = dpkol[i] + dpreg[i] + dphot[i];
dwork = dwork + dtheta * dp[i] * dvar[VE_i][i]; // pumping work [J]
//worksim = dwork;
var_[DPKOL][i]=Math.round(dpkol[i]*1000)/1000;
var_[DPREG][i]=Math.round(dpreg[i]*1000)/1000;
var_[DPHOT][i]=Math.round(dphot[i]*1000)/1000;
pcom[i] = var_[P_i][i];
pexp[i] = var_[P_i][i]+ dp[i];
}
dpkol[COL-1] = dpkol[0];
dpreg[COL-1] = dpreg[0];
dphot[COL-1] = dphot[0];
dp[COL-1] = dp[0];
pcom[COL-1] = pcom[0];
pexp[COL-1] = pexp[0];
for (i = 0; i<37; i++) {
msg_simple5 = msg_simple5 + "\n " + Math.round(pcom[i]*1000)/1000 + "\t" + Math.round(dpkol[i]*1000)/1000 +
"\t" + Math.round(dpreg[i]*1000)/1000 + "\t" + Math.round(dphot[i]*1000)/1000 +
"\t" + Math.round(pexp[i]*1000)/1000;
}
//alert ( msg_simple5);
output2.value = msg_simple5;
}
//******* *******
//******* *******
//******* *******
//******* modul output-func *******
//******* *******
//******* *******
//******* *******
var dia_sl_max;
var dia_sl_num;
step2=8;
document.writeln("<INPUT type='button' value='prev dia' onclick=javascript:slide_back() name='dia_slide_back' style='position:absolute; left:250; top:40'>");
document.writeln("<INPUT type='button' value='next dia' onclick=javascript:slide_forward() name='dia_slide' style='position:absolute; left:250; top:60'>");
dia_sl_max=0;
dia_sl_num=2;
//graph1
a=1;
for (c=0; c<=360; c=c+theta_step) document.writeln("<div id='co_lin" + a + "1" + c + "' style='visibility:hidden; position:absolute; left:" + 10 + "px; top:" + 10 + "px; font-size:6pt; line-height:20pt; font-family:Verdana; font-weight:normal '>__</div>");
for (c=0; c<=360; c=c+theta_step) document.writeln("<div id='co_lin" + a + "2" + c + "' style='visibility:hidden; position:absolute; left:" + 10 + "px; top:" + 10 + "px; font-size:6pt; line-height:20pt; font-family:Verdana; font-weight:normal '>|</div>");
for (b=1; b<=5; b++) {
for (c=0; c<=360; c=c+theta_step) document.writeln("<div id='id" + a + b + c + "' style='visibility:hidden; position:absolute; left:" + 10 + "px; top:" + 10 + "px; font-size:4pt; line-height:20pt; font-family:Verdana; font-weight:normal '>°</div>");
for (c=0; c<=2; c++) document.writeln("<div id='lab" + c + "_id" + a + b + "' style='visibility:hidden; position:absolute; Left:" + 10 + "px; Top:" + 10 + "px; font-size:15pt; line-height:15pt; font-family:Verdana; font-weight:normal; '><INPUT class='coord_label' id='inp" + c + "_id" + a + b + "' ></div>");
document.writeln("<div id='lab" + 3 + "_id" + a + b + "' style='visibility:hidden; position:absolute; Left:" + 10 + "px; Top:" + 10 + "px; font-size:15pt; line-height:15pt; font-family:Verdana; font-weight:normal; '><INPUT class='coord_label' id='inp" + c + "_id" + a + b + "' ></div>");
}
//graph2
a=2;
for (c=0; c<=360; c=c+theta_step) document.writeln("<div id='co_lin" + a + "1" + c + "' style='visibility:hidden; position:absolute; left:" + 10 + "px; top:" + 10 + "px; font-size:6pt; line-height:20pt; font-family:Verdana; font-weight:normal '>__</div>");
for (c=0; c<=360; c=c+theta_step) document.writeln("<div id='co_lin" + a + "2" + c + "' style='visibility:hidden; position:absolute; left:" + 10 + "px; top:" + 10 + "px; font-size:6pt; line-height:20pt; font-family:Verdana; font-weight:normal '>|</div>");
for (b=1; b<=5; b++) {
for (c=0; c<=360; c=c+theta_step) document.writeln("<div id='id" + a + b + c + "' style='visibility:hidden; position:absolute; left:" + 10 + "px; top:" + 10 + "px; font-size:4pt; line-height:20pt; font-family:Verdana; font-weight:normal '>°</div>");
for (c=0; c<=2; c++) {
document.writeln("<div id='lab" + c + "_id" + a + b + "' style='visibility:hidden; position:absolute; Left:" + 10 + "px; Top:" + 10 + "px; font-size:15pt; line-height:15pt; font-family:Verdana; font-weight:normal; '><INPUT class='coord_label' id='inp" + c + "_id" + a + b + "' ></div>");
}
document.writeln("<div id='lab" + 3 + "_id" + a + b + "' style='visibility:hidden; position:absolute; Left:" + 10 + "px; Top:" + 10 + "px; font-size:15pt; line-height:15pt; font-family:Verdana; font-weight:normal; '><INPUT class='coord_label' id='inp" + c + "_id" + a + b + "' ></div>");
}
//graph3
a=3;
for (c=0; c<=360; c=c+theta_step) document.writeln("<div id='co_lin" + a + "1" + c + "' style='visibility:hidden; position:absolute; left:" + 10 + "px; top:" + 10 + "px; font-size:6pt; line-height:20pt; font-family:Verdana; font-weight:normal '>__</div>");
for (c=0; c<=360; c=c+theta_step) document.writeln("<div id='co_lin" + a + "2" + c + "' style='visibility:hidden; position:absolute; left:" + 10 + "px; top:" + 10 + "px; font-size:6pt; line-height:20pt; font-family:Verdana; font-weight:normal '>|</div>");
for (b=1; b<=step2; b++) {
for (c=0; c<=360; c=c+theta_step) document.writeln("<div id='id" + a + b + c + "' style='visibility:hidden; position:absolute; left:" + 10 + "px; top:" + 10 + "px; font-size:4pt; line-height:20pt; font-family:Verdana; font-weight:normal '>°</div>");
for (c=0; c<=2; c++) {
document.writeln("<div id='lab" + c + "_id" + a + b + "' style='visibility:hidden; position:absolute; Left:" + 10 + "px; Top:" + 10 + "px; font-size:15pt; line-height:15pt; font-family:Verdana; font-weight:normal; '><INPUT class='coord_label' id='inp" + c + "_id" + a + b + "' ></div>");
}
document.writeln("<div id='lab" + 3 + "_id" + a + b + "' style='visibility:hidden; position:absolute; Left:" + 10 + "px; Top:" + 10 + "px; font-size:15pt; line-height:15pt; font-family:Verdana; font-weight:normal; '><INPUT class='coord_label' id='inp" + c + "_id" + a + b + "' ></div>");
}
function slide_forward(){
dia_sl_num=dia_sl_num+1;
if (dia_sl_num>dia_sl_max || isNaN(dia_sl_num)) dia_sl_num=0;
slide_dia();
}
function slide_back(){
dia_sl_num=dia_sl_num-1;
if (dia_sl_num<0) dia_sl_num=dia_sl_max;
slide_dia();
}
function slide_dia()
{
slide_event=window.event;
//power_schm.value= (slide_event.type);
pos_top=350;
pos_left=750;
dia_height=150;
dia_width=200;
if (dia_sl_max!=0){
for (a=1; a<=step2; a++) diagram_line (a, 0, 1, var_, "black", a, "hidden", 1, 36, "y", "x");
/*diagram_line (1, 0, 1, var_, "black", 1, "hidden", 1, 36, "y", "x");
diagram_line (2, 0, 1, var_, "black", 2, "hidden", 1, 36, "y", "x");
diagram_line (3, 0, 1, var_, "black", 3, "hidden", 1, 36, "y", "x");
diagram_line (4, 0, 1, var_, "black", 4, "hidden", 1, 36, "y", "x");
diagram_line (5, 0, 1, var_, "black", 5, "hidden", 1, 36, "y", "x");
diagram_line (6, 0, 1, var_, "black", 6, "hidden", 1, 36, "y", "x");
diagram_line (7, 0, 1, var_, "black", 7, "hidden", 1, 36, "y", "x");
*/diagram_line (8, 0, 1, var_, "black", 8, "hidden", 1, 36, "y", "x");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==1) {
diagram_line (17, 0, 1, var_, "blue", 1, "visible", 1, 36, "TCK", "degree");
diagram_line (18, 0, 1, var_, "red", 2, "visible", 1, 36, "THE", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==2){
diagram_line (1, 0, 1, var_, "blue", 1, "visible", 1, 36, "TC", "degree");
diagram_line (2, 0, 1, var_, "red", 2, "visible", 1, 36, "TK", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==3){
diagram_line (12, 0, 1, var_, "blue", 1, "visible", 1, 36, "MC", "degree");
diagram_line (13, 0, 1, var_, "lightblue", 2, "visible", 1, 36, "MK", "degree");
diagram_line (14, 0, 1, var_, "green", 3, "visible", 1, 36, "MR", "degree");
diagram_line (15, 0, 1, var_, "orange", 4, "visible", 1, 36, "MH", "degree");
diagram_line (16, 0, 1, var_, "red", 5, "visible", 1, 36, "ME", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==4){
diagram_line (19, 0, 1, var_, "blue", 1, "visible", 1, 36, "GACK", "degree");
diagram_line (20, 0, 1, var_, "lightblue", 2, "visible", 1, 36, "GAKR", "degree");
diagram_line (21, 0, 1, var_, "orange", 3, "visible", 1, 36, "GARH", "degree");
diagram_line (22, 0, 1, var_, "red", 4, "visible", 1, 36, "GAHE", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==5){
diagram_line (3, 0, 1, var_, "blue", 1, "visible", 1, 36, "QK", "degree");
diagram_line (4, 0, 1, var_, "green", 2, "visible", 1, 36, "QR", "degree");
diagram_line (5, 0, 1, var_, "red", 3, "visible", 1, 36, "QH", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==6){
diagram_line (6, 0, 1, var_, "blue", 1, "visible", 1, 36, "WC", "degree");
diagram_line (7, 0, 1, var_, "red", 2, "visible", 1, 36, "WE", "degree");
diagram_line (8, 0, 1, var_, "black", 3, "visible", 1, 36, "W", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==7) {
diagram_line (9, 10, 1,var_, "red", 1, "visible", 1, 36, "P_exp", "VE");
diagram_line (9, 11, 1, var_, "blue", 2, "visible", 1, 36, "P_comp", "VC");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==8) {
//diagram_line array index for y values, array index for x values, scaling group, array name,
// line color, line number, visibility (visible, hidden), every ... degree (out of 360°), max number of values (out of 360°), label y_axis, label x_axis,...)
//
diagram_line (26, 0, 1, var_, "red", 1, "visible", 1, 36, "Rey_num exp", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==9) {
diagram_line (27, 0, 1, var_, "green", 1, "visible", 1, 36, "Rey_num reg", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==10) {
diagram_line (28, 0, 1, var_, "blue", 1, "visible", 1, 36, "Rey_num comp", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
if (dia_sl_num==11) {
diagram_line (29, 0, 1, var_, "blue", 1, "visible", 1, 36, "dpkol", "degree");
diagram_line (30, 0, 1, var_, "green", 2, "visible", 1, 36, "dpreg", "degree");
diagram_line (31, 0, 1, var_, "red", 3, "visible", 1, 36, "dphot", "degree");
diagram (3, pos_top, pos_left, dia_height, dia_width, "yes");
}
}
theta_step2=theta_step;
function diagram_line (array_ind, array_x_ind, scl_group, array_values, line_color, line_num, line_vis, theta_step, max_step, label_y, label_x){
// y minimum and y maximum values of this line_num
ymax=0;
for (sc=0; sc<=max_step; sc=sc+theta_step){
if (array_values[array_ind][sc] > ymax) ymax = Math.round(array_values[array_ind][sc]*1000000)/1000000;
}
ymin_d = ymax;
for (sc=0; sc<=max_step; sc=sc+theta_step){
if (array_values[array_ind][sc] < ymin_d) ymin_d = Math.round(array_values[array_ind][sc]*1000000)/1000000;
}
// x minimum and x maximum values of this line_num
xmax=0;
for (sc=0; sc<=max_step; sc=sc+theta_step){
if (array_values[array_x_ind][sc] > xmax) xmax = Math.round(array_values[array_x_ind][sc]*10000000)/10000000;
}
xmin = xmax;
for (sc=0; sc<=max_step; sc=sc+theta_step){
if (array_values[array_x_ind][sc] < xmin) xmin = Math.round(array_values[array_x_ind][sc]*10000000)/10000000;
}
plot_scl[line_num][0]=scl_group;
plot_scl[line_num][1]=ymax;
plot_scl[line_num][2]=ymin_d;
//plot_scl[line_num][3]=avg_y;
plot_scl[line_num][4]=xmax;
plot_scl[line_num][5]=xmin;
//plot_scl[line_num][6]=avg_x;
plot_scl[line_num][8]=array_ind;
plot_scl[line_num][9]=array_x_ind;
plot_scl[line_num][10]=line_color;
plot_scl[line_num][11]=line_vis;
plot_scl[line_num][12]=theta_step;
plot_scl[line_num][13]=max_step;
plot_scl[line_num][14]=label_y;
plot_scl[line_num][15]=label_x;
if (ymax>plot_scl[scl_group+10][1] || !plot_scl[scl_group+10][1] ) plot_scl[scl_group+10][1]=ymax;
if (ymin_d<plot_scl[scl_group+10][2] || !plot_scl[scl_group+10][2] ) plot_scl[scl_group+10][2]=ymin_d;
if (xmax>plot_scl[scl_group+10][4] || !plot_scl[scl_group+10][4] ) plot_scl[scl_group+10][4]=xmax;
if (xmin<plot_scl[scl_group+10][5] || !plot_scl[scl_group+10][5] ) plot_scl[scl_group+10][5]=xmin;
//alert ("theta_step" + array_values);
//for (a=0; a<=37; a++){
for (b=0; b<=360; b++) {
plot_var[line_num][array_ind][b]=array_values[array_ind][b];
plot_var[line_num][array_x_ind][b]=array_values[array_x_ind][b];
}
//}
}
function diagram (dia_num, pos_top, pos_left, dia_height, dia_width, coord_lines){
pos_top2=pos_top;
line_num=1;
while (plot_scl[line_num][0]){
//alert (plot_var);
//output.value=plot_var;
scl_group=plot_scl[line_num][0];
ymax=plot_scl[line_num][1];
ymin_d=plot_scl[line_num][2];
ymax_scl=plot_scl[scl_group+10][1];
ymin_scl=plot_scl[scl_group+10][2];
//avg_y=plot_scl[line_num][3];
xmax=plot_scl[scl_group+10][4];
xmin=plot_scl[scl_group+10][5];
//avg_x=plot_scl[line_num][6];
array_ind=plot_scl[line_num][8];
array_x_ind=plot_scl[line_num][9];
line_color=plot_scl[line_num][10];
line_vis=plot_scl[line_num][11];
theta_step=plot_scl[line_num][12];
max_step=plot_scl[line_num][13];
label_y=plot_scl[line_num][14];
label_x=plot_scl[line_num][15];
yminmax=ymax_scl;
if (ymin_scl<0) yminmax=Math.abs(ymax_scl)+Math.abs(ymin_scl);
if (ymax_scl) y_scl=dia_height/yminmax; //var_ymax - var_ymin_d
if (ymin_scl<0) pos_top2=pos_top+ymin_scl*y_scl;
if (xmax ) x_scl=dia_width/xmax; //var_xmax - var_xmin
txt=navigator.userAgent;
if (txt.search("MSIE 6.0")>=0 && (navigator.userAgent.search("Opera")<0)) {
for (theta=0; theta<=360; theta=theta+theta_step*360/max_step){
//diagram lines
id = "id"+ dia_num + line_num + theta;
objs = document.getElementById(id);
objs.style.visibility = line_vis;
objs.style.color = line_color ;
objs.style.pixelTop =pos_top2-Math.round(plot_var[line_num][array_ind][parseInt(theta*max_step/360)]*y_scl);
objs.style.pixelLeft = pos_left+Math.round(plot_var[line_num][array_x_ind][parseInt(theta*max_step/360)]*x_scl);
}
// inscription of coordinate system
// y-axis
if (label_y!="") {
unit_width=40;
objs=document.getElementById("lab0_id" + dia_num + line_num);
//alert (objs.style.pixelLeft + " " + objs.id);
objs.style.visibility=line_vis;
objs.style.color=line_color;
objs.style.pixelTop=pos_top-dia_height-20;
objs.style.pixelLeft=Math.round(pos_left +dia_width+line_num*unit_width);
//objs.style.width=5;
objs=document.getElementById("inp0_id" + dia_num + line_num);
objs.value=label_y;
objs.style.color=line_color;
//objs.width=15;
//objs.style.border="none";
objs=document.getElementById("lab1_id" + dia_num + line_num);
objs.style.visibility=line_vis;
objs.style.color=line_color;
objs.style.pixelTop=pos_top2-ymin_d*y_scl;
if (ymax*y_scl-ymin_d*y_scl <12) objs.style.pixelTop=pos_top2-ymax*y_scl+12;
objs.style.pixelLeft=Math.round(pos_left+dia_width+line_num*unit_width);
//objs.style.width=5;
objs=document.getElementById("inp1_id" + dia_num + line_num);
objs.value=ymin_d;
objs.width=15;
objs.style.color=line_color;
//objs.style.border=thin;
objs=document.getElementById("lab2_id" + dia_num + line_num);
objs.style.visibility=line_vis;
objs.style.color=line_color;
objs.style.pixelTop=pos_top2-ymax*y_scl;
objs.style.pixelLeft=Math.round(pos_left+dia_width+line_num*unit_width);
//objs.style.width=5;
objs=document.getElementById("inp2_id" + dia_num + line_num);
objs.value=ymax;
objs.width=15;
objs.style.color=line_color;
//objs.style.border=thin;
}
// x-axis
if (label_x!="") {
objs=document.getElementById("lab3_id" + dia_num + "1");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.pixelTop=pos_top+40;
objs.style.pixelLeft=Math.round(pos_left+xmin*x_scl);
//objs.style.width=5;
//alert (objs.id);
objs=document.getElementById("inp3_id" + dia_num + "1");
objs.value=xmin;
objs=document.getElementById("lab3_id" + dia_num + "2");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.pixelTop=pos_top+60;
objs.style.pixelLeft=Math.round(pos_left+(((xmax-xmin)/4)+xmin)*x_scl);
//objs.style.width=5;
objs=document.getElementById("inp3_id" + dia_num + "2");
objs.value=Math.round((((xmax-xmin)/4)+xmin)*1000000)/1000000;
objs=document.getElementById("lab3_id" + dia_num + "3");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.pixelTop=pos_top+40;
objs.style.pixelLeft=Math.round(pos_left+(((xmax-xmin)/2)+xmin)*x_scl);
//objs.style.width=5;
objs=document.getElementById("inp3_id" + dia_num + "3");
objs.value=Math.round((((xmax-xmin)/2)+xmin)*1000000)/1000000;
objs=document.getElementById("lab3_id" + dia_num + "4");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.pixelTop=pos_top+60;
objs.style.pixelLeft=Math.round(pos_left+(((xmax-xmin)/4*3)+xmin)*x_scl);
//objs.style.width=5;
objs=document.getElementById("inp3_id" + dia_num + "4");
objs.value=Math.round((((xmax-xmin)/4*3)+xmin)*1000000)/1000000;
objs=document.getElementById("lab3_id" + dia_num + "5");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.pixelTop=pos_top+40;
objs.style.pixelLeft=Math.round(pos_left+xmax*x_scl);
//objs.style.width=5;
objs=document.getElementById("inp3_id" + dia_num + "5");
objs.value=xmax;
}
plot_scl[line_num][0]="";
line_num=line_num+1;
}
else {
for (theta=0; theta<=360; theta=theta+theta_step*360/max_step){
//diagram lines
id = "id"+ dia_num + line_num + theta;
objs = document.getElementById(id);
objs.style.visibility = line_vis;
objs.style.color = line_color ;
objs.style.top =pos_top2-Math.round(plot_var[line_num][array_ind][parseInt(theta*max_step/360)]*y_scl);
objs.style.left = pos_left+Math.round(plot_var[line_num][array_x_ind][parseInt(theta*max_step/360)]*x_scl);
}
//alert (dia_num + " " + line_num);
// inscription of coordinate system
// y-axis
if (label_y!="") {
unit_width=40;
objs=document.getElementById("lab0_id" + dia_num + line_num);
objs.style.visibility=line_vis;
objs.style.color=line_color;
objs.style.top=pos_top-dia_height-20;
objs.style.left=Math.round(pos_left +dia_width+line_num*unit_width);
//objs.style.width=5;
//alert (objs.style.left + " " + objs.id);
objs=document.getElementById("inp0_id" + dia_num + line_num);
objs.value=label_y;
objs.style.color=line_color;
//objs.width=15;
//objs.style.border="none";
objs=document.getElementById("lab1_id" + dia_num + line_num);
objs.style.visibility=line_vis;
objs.style.color=line_color;
objs.style.top=pos_top2-ymin_d*y_scl;
if (ymax*y_scl-ymin_d*y_scl <12) objs.style.pixelTop=pos_top2-ymax*y_scl+12;
objs.style.left=Math.round(pos_left+dia_width+line_num*unit_width);
//objs.style.width=5;
objs=document.getElementById("inp1_id" + dia_num + line_num);
objs.value=ymin_d;
objs.width=15;
objs.style.color=line_color;
//objs.style.border=thin;
objs=document.getElementById("lab2_id" + dia_num + line_num);
objs.style.visibility=line_vis;
objs.style.color=line_color;
objs.style.top=pos_top2-ymax*y_scl;
objs.style.left=Math.round(pos_left+dia_width+line_num*unit_width);
//objs.style.width=5;
objs=document.getElementById("inp2_id" + dia_num + line_num);
objs.value=ymax;
objs.width=15;
objs.style.color=line_color;
//objs.style.border=thin;
}
// x-axis
if (label_x!="") {
objs=document.getElementById("lab3_id" + dia_num + "1");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.top=pos_top+40;
objs.style.left=Math.round(pos_left+xmin*x_scl);
//objs.style.width=5;
//alert (objs.id);
objs=document.getElementById("inp3_id" + dia_num + "1");
objs.value=xmin;
objs=document.getElementById("lab3_id" + dia_num + "2");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.top=pos_top+60;
objs.style.left=Math.round(pos_left+(((xmax-xmin)/4)+xmin)*x_scl);
//objs.style.width=5;
objs=document.getElementById("inp3_id" + dia_num + "2");
objs.value=Math.round((((xmax-xmin)/4)+xmin)*1000000)/1000000;
objs=document.getElementById("lab3_id" + dia_num + "3");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.top=pos_top+40;
objs.style.left=Math.round(pos_left+(((xmax-xmin)/2)+xmin)*x_scl);
//objs.style.width=5;
objs=document.getElementById("inp3_id" + dia_num + "3");
objs.value=Math.round((((xmax-xmin)/2)+xmin)*1000000)/1000000;
objs=document.getElementById("lab3_id" + dia_num + "4");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.top=pos_top+60;
objs.style.left=Math.round(pos_left+(((xmax-xmin)/4*3)+xmin)*x_scl);
//objs.style.width=5;
objs=document.getElementById("inp3_id" + dia_num + "4");
objs.value=Math.round((((xmax-xmin)/4*3)+xmin)*1000000)/1000000;
objs=document.getElementById("lab3_id" + dia_num + "5");
objs.style.visibility=line_vis;
//objs.style.color=line_color;
objs.style.top=pos_top+40;
objs.style.left=Math.round(pos_left+xmax*x_scl);
//objs.style.width=5;
objs=document.getElementById("inp3_id" + dia_num + "5");
objs.value=xmax;
}
plot_scl[line_num][0]="";
line_num=line_num+1;
}
for (theta=0; theta<=360; theta=theta+theta_step*360/max_step){
//lines of coordinate system
id = "co_lin" + dia_num + "1" + theta;
objs = document.getElementById(id);
if (coord_lines=="yes") objs.style.visibility = "visible";
if (coord_lines=="no") objs.style.visibility = "hidden";
objs.style.color = "black";
objs.style.top = pos_top2;
objs.style.left = pos_left + theta*x_scl;
id = "co_lin" + dia_num + "2" + theta;
objs = document.getElementById(id);
if (coord_lines=="yes") objs.style.visibility = "visible";
if (coord_lines=="no") objs.style.visibility = "hidden";
objs.style.color = "black";
objs.style.top = pos_top -2- ((dia_height)*theta/360);
objs.style.left = pos_left;
}
}
for (a=0; a<plot_scl.length;a++){
plot_scl[a][1]="";
plot_scl[a][2]="";
plot_scl[a][4]="";
plot_scl[a][5]="";
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! must be corrected,
theta_step=theta_step2;
//alert (theta_step2);
//theta_step=10;
}
//--></script>
</body >
</HTML>