Changeset 2:9f66d9059763 for source/class
- Timestamp:
- Jul 4, 2007, 12:22:14 PM (17 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- source/class/pf
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/class/pf/Application.js
r1 r2 14 14 15 15 ************************************************************************ */ 16 17 18 var plasma_entities = new Array( 19 { 20 name : "Gyrofrequency", 21 dimension : "frequency", 22 nspecies : 1, 23 section : "fundamental", 24 formula : "%s1.getGyroFrequency(this.B)" 25 }, 26 { 27 name : "Plasma frequency", 28 dimension : "frequency", 29 nspecies : 1, 30 section : "fundamental", 31 formula : "%s1.getPlasmaFrequency()" 32 }, 33 34 { 35 name : "Debye length", 36 dimension : "length", 37 nspecies : 1, 38 section : "fundamental", 39 formula : "%s1.getDebyeLength()" 40 }, 41 { 42 name : "deBroglie length", 43 dimension : "length", 44 nspecies : 1, 45 section : "fundamental", 46 formula : "%s1.getDeBroglieLength()" 47 }, 48 { 49 name : "Mean interparticle distance", 50 dimension : "length", 51 nspecies : 1, 52 section : "fundamental", 53 formula : "%s1.getMeanDistance()" 54 }, 55 { 56 name : "Distance of minimal approach", 57 dimension : "length", 58 nspecies : 1, 59 section : "fundamental", 60 formula : "%s1.getMinApproachDistance()" 61 }, 62 63 { 64 name : "Thermal velocity", 65 dimension : "velocity", 66 nspecies : 1, 67 section : "fundamental", 68 formula : "%s1.getThermalVelocity()" 69 }, 70 71 { 72 name : "Coupling parameter", 73 dimension : "none", 74 nspecies : 1, 75 section : "fundamental", 76 formula : "%s1.getCoupling()" 77 }, 78 { 79 name : "Typical Debye screening", 80 dimension : "none", 81 nspecies : 1, 82 section : "spectroscopy", 83 formula : "var r = %s1.getMeanDistance()/%s1.getDebyeLength(); \ 84 (1 + r)*Math.exp(-r)" 85 }, 86 87 { 88 name : "Holtsmark field", 89 dimension : "efield", 90 nspecies : 1, 91 section : "spectroscopy", 92 formula : "%s1.getHoltsmarkField()" 93 } 94 ); 95 96 97 16 98 17 99 function NumPrint(v) … … 21 103 s = "0"; 22 104 } else 23 if (Math.abs(v) < 1.e6) { 105 if (!isFinite(v)) { 106 s = v; 107 } else 108 if (Math.abs(v) < 1.e6 && Math.abs(v) >= 0.1) { 24 109 s = sprintf("%.3f", v); 25 110 } else { … … 30 115 } 31 116 32 function changeN_e(e )33 { 34 var N_e = this.gui_N_e.getNumValue();35 36 if (isFinite(N_e)) {37 this.N_e = N_e;117 function changeN_e(ev) 118 { 119 var e = ev.getTarget(); 120 var N_e = e.getNumValue(); 121 122 if (isFinite(N_e) && this.e.setN(N_e)) { 38 123 this.updatePlasmaParameters(); 39 this.gui_N_i.setNumValue(this.N_i); 40 this.gui_N_r.setNumValue(this.N_r); 41 } 42 } 43 44 function changeZ_i(e) 45 { 46 var Z_i = parseInt(this.gui_Z_i.getValue()); 124 this.updateGUI(); 125 } 126 } 127 128 function changeT_e(ev) 129 { 130 var e = ev.getTarget(); 131 var T_e = e.getNumValue(); 132 133 if (isFinite(T_e)) { 134 this.e.setT(T_e); 135 this.updateGUI(); 136 } 137 } 138 139 function changeZ_i(ev) 140 { 141 var e = ev.getTarget(); 142 var Z_i = parseInt(e.getValue()); 47 143 48 144 if (isFinite(Z_i)) { 49 this. Z_i = Z_i;145 this.i.setQ(Z_i); 50 146 this.updatePlasmaParameters(); 51 this.gui_N_i.setNumValue(this.N_i); 52 this.gui_N_r.setNumValue(this.N_r); 53 } 54 } 55 56 function changeZ_r(e) 57 { 58 var Z_r = parseInt(this.gui_Z_r.getValue()); 147 this.updateGUI(); 148 } 149 } 150 151 function changeT_i(ev) 152 { 153 var e = ev.getTarget(); 154 var T_i = e.getNumValue(); 155 156 if (isFinite(T_i)) { 157 this.i.setT(T_i); 158 this.updateGUI(); 159 } 160 } 161 162 function changeZ_r(ev) 163 { 164 var e = ev.getTarget(); 165 var Z_r = parseInt(e.getValue()); 59 166 60 167 if (isFinite(Z_r)) { 61 this. Z_r = Z_r;168 this.r.setQ(Z_r); 62 169 this.updatePlasmaParameters(); 63 this. gui_N_i.setNumValue(this.N_i);64 this.gui_N_r.setNumValue(this.N_r);65 66 } 67 68 function changeP_r(e) 69 { 70 var P_r = parseInt( this.gui_P_r.getValue())/100.0;170 this.updateGUI(); 171 } 172 } 173 174 function changeP_r(ev) 175 { 176 var e = ev.getTarget(); 177 var P_r = parseInt(e.getValue())/100.0; 71 178 72 179 if (isFinite(P_r)) { 73 180 this.P_r = P_r; 74 181 this.updatePlasmaParameters(); 75 this.gui_N_i.setNumValue(this.N_i); 76 this.gui_N_r.setNumValue(this.N_r); 77 } 78 } 79 80 function changeB(e) 81 { 82 var v = this.gui_B.getNumValue(); 182 this.updateGUI(); 183 } 184 } 185 186 function changeT_r(ev) 187 { 188 var e = ev.getTarget(); 189 var T_r = e.getNumValue(); 190 191 if (isFinite(T_r)) { 192 this.r.setT(T_r); 193 this.updateGUI(); 194 } 195 } 196 197 function changeM_i(ev) 198 { 199 var e = ev.getTarget(); 200 var M_i = parseInt(e.getValue()); 201 202 if (isFinite(M_i)) { 203 this.i.setM(M_i); 204 this.updateGUI(); 205 } 206 } 207 208 function changeM_r(ev) 209 { 210 var e = ev.getTarget(); 211 var M_r = parseInt(e.getValue()); 212 213 if (isFinite(M_r)) { 214 this.r.setM(M_r); 215 this.updateGUI(); 216 } 217 } 218 219 function changeB(ev) 220 { 221 var e = ev.getTarget(); 222 var v = e.getNumValue(); 83 223 84 224 if (isFinite(v)) { 85 225 this.B = v; 86 226 } 227 } 228 229 function clickPropertyCB(ev) 230 { 231 var e = ev.getTarget(); 232 var entity = e.getUserData("entity"); 233 var species = e.getUserData("species"); 234 var species_str = "this." + species.id; 235 var formula = entity.formula.replace(/\%s1/g, species_str); 236 237 var v = eval(formula); 238 this.gui_entity_value.setNumValue(v); 87 239 } 88 240 … … 105 257 checkPlasmaParameters : function() 106 258 { 107 if (this.N_e <= 0.0 || 108 (this.P_r < 0.0 || this.P_r > 1.0) || 259 if ((this.P_r < 0.0 || this.P_r > 1.0) || 109 260 this.Z_i < 1 || 110 261 this.P_r == 1.0 && this.Z_r == 0) { … … 122 273 } 123 274 275 var N_e = this.e.getN(); 276 var N_i, N_r; 277 124 278 if (this.P_r < 1.0) { 125 this.N_i = this.N_e*(1.0 - this.P_r)/126 (this. Z_i*(1.0 - this.P_r) + this.Z_r*this.P_r);279 N_i = N_e*(1.0 - this.P_r)/ 280 (this.i.getQ()*(1.0 - this.P_r) + this.r.getQ()*this.P_r); 127 281 128 this.N_r = this.N_i*this.P_r/(1.0 - this.P_r);282 N_r = N_i*this.P_r/(1.0 - this.P_r); 129 283 } else { 130 this.N_i = 0.0;131 this.N_r = this.N_e/this.Z_r;284 N_i = 0.0; 285 N_r = N_e/this.r.getQ(); 132 286 } 133 287 288 this.i.setN(N_i); 289 this.r.setN(N_r); 290 134 291 return true; 292 }, 293 294 updateGUI : function() 295 { 296 this.gui_N_i.setNumValue(this.i.getN()); 297 this.gui_N_r.setNumValue(this.r.getN()); 135 298 }, 136 299 … … 151 314 152 315 // Defaults 153 this.N_e = 1e16; 154 this.Z_i = 1; 155 this.Z_r = 0; 316 317 this.r = new pf.base.Species("r", 1.0, 0, 0, 1.0, null); 318 this.e = new pf.base.Species("e", (1.0/1836.2), -1, 1e16, 1.0, this.r); 319 this.i = new pf.base.Species("i", 1.0, +1, 1e16, 1.0, this.r); 320 156 321 this.P_r = 0; 157 322 158 this.T_e = 1;159 this.T_i = 1;160 this.T_r = 1;161 162 this.M_i = 1;163 this.M_r = 1;164 165 323 this.B = 0; 166 324 … … 169 327 } 170 328 329 330 // Top-level container 331 this.bl_top = new qx.ui.layout.VerticalBoxLayout("vertical"); 332 333 this.bl_top.addToDocument(); 334 335 336 // The toolbar 337 var tb = new qx.ui.toolbar.ToolBar; 338 this.bl_top.add(tb); 339 340 // ... and the buttons themselves 341 342 var sep = new qx.ui.toolbar.Separator; 343 tb.add(sep); 344 345 var btn = new qx.ui.toolbar.Button("About..."); 346 tb.add(btn); 347 // btn.addEventListener("execute", this.aboutCB, this); 348 349 var tf1 = new qx.ui.pageview.tabview.TabView; 350 // tf1.setSpacing(0); 351 this.bl_top.add(tf1); 352 353 this.tabbar = tf1.getBar(); 354 this.tabpane = tf1.getPane(); 355 this.tabpane.setPadding(0, 0, 0, 0); 356 this.tabpane.setBackgroundColor("white"); 357 358 359 var tab_id = new qx.ui.pageview.tabview.Button("Parameters"); 360 this.tabbar.add(tab_id); 361 var page_id = new qx.ui.pageview.tabview.Page(tab_id); 362 this.tabpane.add(page_id); 363 171 364 172 365 var fr, gl; 173 366 var l, e; 174 367 175 fr = new qx.ui.groupbox.GroupBox("Electrons"); 368 fr = new qx.ui.groupbox.GroupBox("Electrons", 369 "pf/image/e_small.png"); 176 370 fr.setDimension("auto", "auto"); 177 fr.setBackgroundColor("#ffeeee"); 178 179 fr.addToDocument(); 371 fr.setBackgroundColor("#eeeeff"); 372 373 // fr.addToDocument(); 374 page_id.add(fr); 180 375 181 376 gl = new qx.ui.layout.GridLayout; … … 194 389 l = new qx.ui.basic.Label("N<sub>e</sub> (cm<sup>-3</sup>):"); 195 390 gl.add(l, 0, 0); 196 e = new pf.ui.TextField(this. N_e);391 e = new pf.ui.TextField(this.e.getN()); 197 392 gl.add(e, 1, 0); 198 e.setLiveUpdate(true);393 // e.setLiveUpdate(true); 199 394 e.addEventListener("changeValue", changeN_e, this); 200 this.gui_N_e = e;201 395 202 396 // T_e 203 397 l = new qx.ui.basic.Label("T<sub>e</sub> (eV):"); 204 398 gl.add(l, 0, 1); 205 e = new pf.ui.TextField(this. T_e);399 e = new pf.ui.TextField(this.e.getT()); 206 400 gl.add(e, 1, 1); 207 208 209 fr = new qx.ui.groupbox.GroupBox("Ions"); 401 e.addEventListener("changeValue", changeT_e, this); 402 403 404 fr = new qx.ui.groupbox.GroupBox("Ions", 405 "pf/image/i_small.png"); 210 406 fr.setDimension("auto", "auto"); 211 fr.setBackgroundColor("#eeeeff"); 212 213 fr.addToDocument(); 407 fr.setBackgroundColor("#ffeeee"); 408 409 page_id.add(fr); 410 // fr.addToDocument(); 214 411 fr.setTop(100); 215 412 … … 231 428 l = new qx.ui.basic.Label("Z<sub>i</sub>:"); 232 429 gl.add(l, 0, 0); 233 e = new qx.ui.form.Spinner(1, this. Z_i, 100);430 e = new qx.ui.form.Spinner(1, this.i.getQ(), 100); 234 431 gl.add(e, 1, 0); 235 432 236 433 e.addEventListener("change", changeZ_i, this); 237 434 238 this.gui_Z_i = e;239 240 435 // M_i 241 436 l = new qx.ui.basic.Label("M<sub>i</sub>:"); 242 437 gl.add(l, 0, 1); 243 e = new qx.ui.form.Spinner(1, this. M_i, 200);438 e = new qx.ui.form.Spinner(1, this.i.getM(), 200); 244 439 gl.add(e, 1, 1); 245 this.gui_M_i = e;440 e.addEventListener("change", changeM_i, this); 246 441 247 442 // T_i 248 443 l = new qx.ui.basic.Label("T<sub>i</sub> (eV):"); 249 444 gl.add(l, 0, 2); 250 e = new pf.ui.TextField(this. T_i);445 e = new pf.ui.TextField(this.i.getT()); 251 446 gl.add(e, 1, 2); 447 e.addEventListener("changeValue", changeT_i, this); 252 448 253 449 // N_i 254 450 l = new qx.ui.basic.Label("N<sub>i</sub> (cm<sup>-3</sup>):"); 255 451 gl.add(l, 0, 3); 256 e = new pf.ui.TextField(this. N_i);452 e = new pf.ui.TextField(this.i.getN()); 257 453 gl.add(e, 1, 3); 258 454 e.setReadOnly(true); … … 260 456 261 457 262 fr = new qx.ui.groupbox.GroupBox("Radiators"); 458 fr = new qx.ui.groupbox.GroupBox("Radiators", 459 "pf/image/r_small.png"); 263 460 fr.setDimension("auto", "auto"); 264 461 fr.setBackgroundColor("#eeffee"); 265 462 266 fr.addToDocument(); 463 page_id.add(fr); 464 // fr.addToDocument(); 267 465 fr.setLeft(330); 268 466 … … 289 487 gl.add(e, 1, 0); 290 488 e.addEventListener("change", changeZ_r, this); 291 this.gui_Z_r = e;292 489 293 490 // M_r 294 491 l = new qx.ui.basic.Label("M<sub>r</sub>:"); 295 492 gl.add(l, 0, 1); 296 e = new qx.ui.form.Spinner(1, this. M_r, 200);493 e = new qx.ui.form.Spinner(1, this.r.getM(), 200); 297 494 gl.add(e, 1, 1); 298 this.gui_M_r = e;495 e.addEventListener("change", changeM_r, this); 299 496 300 497 // T_r 301 498 l = new qx.ui.basic.Label("T<sub>r</sub> (eV):"); 302 499 gl.add(l, 0, 2); 303 e = new pf.ui.TextField(this. T_r);500 e = new pf.ui.TextField(this.r.getT()); 304 501 gl.add(e, 1, 2); 502 e.addEventListener("changeValue", changeT_r, this); 305 503 306 504 // P_r … … 310 508 gl.add(e, 1, 3); 311 509 e.addEventListener("change", changeP_r, this); 312 this.gui_P_r = e;313 510 314 511 // N_r 315 512 l = new qx.ui.basic.Label("N<sub>r</sub> (cm<sup>-3</sup>):"); 316 513 gl.add(l, 0, 4); 317 e = new pf.ui.TextField(this. N_r);514 e = new pf.ui.TextField(this.r.getN()); 318 515 e.setReadOnly(true); 319 516 gl.add(e, 1, 4); … … 325 522 fr.setBackgroundColor("#ffffdd"); 326 523 327 fr.addToDocument(); 524 page_id.add(fr); 525 // fr.addToDocument(); 328 526 329 527 gl = new qx.ui.layout.GridLayout; … … 345 543 e = new pf.ui.TextField(this.B); 346 544 gl.add(e, 1, 0); 347 e.setLiveUpdate(true);545 // e.setLiveUpdate(true); 348 546 e.addEventListener("changeValue", changeB, this); 349 this.gui_B = e; 547 548 tab_id.setChecked(true); 549 550 var tab_id = new qx.ui.pageview.tabview.Button("Explorer"); 551 this.tabbar.add(tab_id); 552 var page_id = new qx.ui.pageview.tabview.Page(tab_id); 553 this.tabpane.add(page_id); 554 page_id.setDimension(600, 400); 555 page_id.setBackgroundColor("black"); 556 557 var sp = new qx.ui.splitpane.HorizontalSplitPane(200, "1*"); 558 sp.set( 559 { 560 left : 5, 561 right : 5, 562 top : 5, 563 bottom : 5, 564 border : "inset-thin", 565 backgroundColor : "white", 566 showKnob : true 567 }); 568 569 var fff = new qx.ui.layout.CanvasLayout(); 570 fff.set( 571 { 572 width: 600, 573 height: 400 574 }); 575 576 page_id.add(fff); 577 fff.add(sp); 578 579 var left_pane = sp.getLeftArea(); 580 left_pane.setPaddingRight(4); 581 var right_pane = sp.getRightArea(); 582 right_pane.setPaddingLeft(4); 583 var tree = new qx.ui.tree.Tree("Browser"); 584 tree.set( 585 { 586 top : 4, 587 left : 4, 588 bottom : 4, 589 backgroundColor : "white", 590 border : "inset-thin", 591 overflow : "scroll", 592 height : "100%", 593 width : "100%", 594 paddingLeft : 4, 595 paddingTop : 4 596 }); 597 left_pane.add(tree); 598 599 folder = new qx.ui.tree.TreeFolder("Frequencies"); 600 tree.add(folder); 601 this.gui_folder_freq = folder; 602 603 var folder = new qx.ui.tree.TreeFolder("Lengths"); 604 tree.add(folder); 605 this.gui_folder_length = folder; 606 607 var folder = new qx.ui.tree.TreeFolder("Velocities"); 608 tree.add(folder); 609 this.gui_folder_vel = folder; 610 611 folder = new qx.ui.tree.TreeFolder("Dimensionless"); 612 tree.add(folder); 613 this.gui_folder_none = folder; 614 615 folder = new qx.ui.tree.TreeFolder("Miscellaneous"); 616 tree.add(folder); 617 this.gui_folder_misc = folder; 618 619 var i, n = plasma_entities.length; 620 var sa = new Array(this.e, this.i, this.r); 621 for (var i = 0; i < n; i++) { 622 var entity = plasma_entities[i]; 623 624 for (var j = 0; j < 3; j++) { 625 var s = sa[j]; 626 var icon = "pf/image/" + s.id + "_small.png"; 627 628 var leaf = new qx.ui.tree.TreeFile(entity.name, icon); 629 leaf.addEventListener("click", clickPropertyCB, this); 630 leaf.setUserData("entity", entity); 631 leaf.setUserData("species", s); 632 633 var folder; 634 switch (entity.dimension) { 635 case "frequency": 636 folder = this.gui_folder_freq; 637 break; 638 case "length": 639 folder = this.gui_folder_length; 640 break; 641 case "velocity": 642 folder = this.gui_folder_vel; 643 break; 644 case "none": 645 folder = this.gui_folder_none; 646 break; 647 default: 648 folder = this.gui_folder_misc; 649 break; 650 } 651 folder.add(leaf); 652 } 653 654 } 655 656 657 gl = new qx.ui.layout.GridLayout; 658 gl.set( 659 { 660 left: 4, 661 right: 4, 662 top: 4 663 }); 664 665 gl.setVerticalSpacing(4); 666 gl.setHorizontalSpacing(6); 667 gl.setColumnCount(2); 668 gl.setColumnWidth(0, "30%"); 669 gl.setColumnWidth(1, "65%"); 670 gl.setRowCount(3); 671 gl.setRowHeight(0, 30); 672 gl.setRowHeight(1, 30); 673 gl.setRowHeight(2, 30); 674 675 676 l = new qx.ui.basic.Label("Value:"); 677 gl.add(l, 0, 0); 678 e = new pf.ui.TextField(""); 679 e.setReadOnly(true); 680 gl.add(e, 1, 0); 681 this.gui_entity_value = e; 682 683 right_pane.add(gl); 350 684 351 685 },
Note: See TracChangeset
for help on using the changeset viewer.