bem_sweep.tcl 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228
  1. #----------------------------------------------*-TCL-*------------
  2. #
  3. # mmtl_sweep.tcl
  4. #
  5. # Copyright 2002-2004 Mayo Foundation. All Rights Reserved.
  6. # $Id: bem_sweep.tcl,v 1.7 2004/07/28 15:40:53 techenti Exp $
  7. #
  8. #----------------------------------------------*-TCL-*------------
  9. package provide bem 1.0
  10. #--------------------------------------------------------
  11. #
  12. # ::bem::runSweep
  13. #
  14. # Run multiple MMTL simulations, while sweeping
  15. # one or more parameters.
  16. #
  17. # This procedure creates the dialog of checkbuttons
  18. # and entries which control building of the
  19. # simulation sweep script. The script is
  20. # written based on a number of array entries
  21. # in ::bem::
  22. #
  23. #--------------------------------------------------------
  24. proc ::bem::runSweep { nodename cSegs pSegs } {
  25. #--------------------------------------------------------
  26. # Create dialog, from scratch
  27. #--------------------------------------------------------
  28. set dlg .sweepBEM
  29. if { [winfo exists $dlg] } {destroy $dlg}
  30. Dialog $dlg -title "BEM MMTL Parameter Sweep" \
  31. -cancel 1 -modal none -transient 0
  32. $dlg add -text Run
  33. $dlg add -text Cancel
  34. #--------------------------------------------------------
  35. # Create a scrollable frame in a scrolled window
  36. # to hold the entries. Set column properties for resize.
  37. #--------------------------------------------------------
  38. set dlgframe [$dlg getframe]
  39. set sw [ScrolledWindow $dlgframe.sw]
  40. set sf [ScrollableFrame $sw.sf -constrainedwidth 1 ]
  41. $sw setwidget $sf
  42. set f [$sf getframe]
  43. grid columnconfigure $f {2 3 4} -weight 1
  44. #--------------------------------------------------------
  45. # Column headings
  46. #--------------------------------------------------------
  47. set l1 [label $f.lname -text "Parameter"]
  48. set l2 [label $f.lstart -text "Start Value"]
  49. set l3 [label $f.lend -text "End Value"]
  50. set l4 [label $f.lnum -text "Iterations"]
  51. grid x $l1 $l2 $l3 $l4 -padx 4 -pady 4
  52. #--------------------------------------------------------
  53. # Entries for "basic" parameters
  54. #--------------------------------------------------------
  55. set basicLabel [label $f.label-basicSim -text "Simulation"]
  56. set labelRow [lindex [grid size $f] 1]
  57. sweepEntry $f "Conductor Segments" ::bem::_doCseg \
  58. ::bem::_startcs ::bem::_endcs ::bem::_numcs
  59. set ::bem::_startcs $cSegs
  60. sweepEntry $f "Dielectric Segments" ::bem::_doPseg \
  61. ::bem::_startps ::bem::_endps ::bem::_numps
  62. set ::bem::_startps $pSegs
  63. sweepEntry $f "Coupling Length" ::bem::_doClngLgt \
  64. ::bem::_startcl ::bem::_endcl ::bem::_numcl
  65. set ::bem::_startcl $::Stackup::couplingLength
  66. sweepEntry $f "Rise Time" ::bem::_doRseTme \
  67. ::bem::_startrt ::bem::_endrt ::bem::_numrt
  68. set ::bem::_startrt $::Stackup::riseTime
  69. grid $basicLabel -row $labelRow -sticky sw -padx 4 -pady 4
  70. #--------------------------------------------------------
  71. # Initialize arrays controlling sweep iterations
  72. # Arrays are indexed by $struct-$varname
  73. #--------------------------------------------------------
  74. array unset _sweepFlag
  75. array unset _sweepStart
  76. array unset _sweepEnd
  77. array unset _sweepCount
  78. #--------------------------------------------------------
  79. # Walk the Stackup, adding parameters for each structure
  80. #--------------------------------------------------------
  81. foreach struct $::Stackup::structureList {
  82. set structName [namespace tail $struct]
  83. set structClass [namespace tail [$struct info class]]
  84. #--------------------------------------------------------
  85. # Choose sweep-able parameters based on
  86. # the struct class. We could just call
  87. # 'configure' and get a list, but it would
  88. # be in alphabetical order...
  89. #--------------------------------------------------------
  90. switch -exact -- $structClass {
  91. GroundPlane {
  92. set parameters {thickness}
  93. }
  94. DielectricLayer {
  95. set parameters {permittivity permeability lossTangent
  96. thickness}
  97. }
  98. RectangleDielectric {
  99. set parameters {permittivity permeability lossTangent
  100. width height
  101. number pitch "x Offset" "y Offset"}
  102. }
  103. RectangleConductors {
  104. set parameters {conductivity width height
  105. number pitch "x Offset" "y Offset"}
  106. }
  107. TrapezoidConductors {
  108. set parameters {conductivity topwidth bottomWidth height
  109. number pitch "x Offset" "y Offset"}
  110. }
  111. CircleConductors {
  112. set parameters {conductivity diameter
  113. number pitch "x Offset" "y Offset"}
  114. }
  115. default {
  116. puts stderr "Warning: Structure $struct has unknown class $structClass"
  117. }
  118. }
  119. #--------------------------------------------------------
  120. # Check if we want this structure on the dialog
  121. #--------------------------------------------------------
  122. if { [llength $parameters] < 1 } {
  123. continue
  124. }
  125. #--------------------------------------------------------
  126. # Create a Title label for this structure
  127. # (Can't grid it until after sweepEntries are
  128. # created.)
  129. #--------------------------------------------------------
  130. set structLabel [label $f.label-$structName -text $structName]
  131. set labelRow [lindex [grid size $f] 1]
  132. #--------------------------------------------------------
  133. # Create parameter lines within the title frame
  134. #--------------------------------------------------------
  135. foreach p $parameters {
  136. set varname [string map {" " ""} $p]
  137. set label [string totitle $p]
  138. set index "$struct-$varname"
  139. sweepEntry $f $label ::bem::_sweepFlag($index) \
  140. ::bem::_sweepStart($index) ::bem::_sweepEnd($index) \
  141. ::bem::_sweepCount($index)
  142. set ::bem::_sweepStart($index) [$struct cget -$varname]
  143. }
  144. grid $structLabel -row $labelRow -column 0 -sticky sw -padx 4 -pady 4
  145. }
  146. #--------------------------------------------------------
  147. # Final sizing for the dialog.
  148. # Note that the scrolled window won't automatically
  149. # take on the size of the contained widgets.
  150. # So we call update to compute the size of the
  151. # enclosing grid frame, then insist that the
  152. # scrollable frame have the correct width.
  153. #--------------------------------------------------------
  154. pack $sw -expand y -fill both
  155. update idletasks
  156. set w [winfo width $sf.frame]
  157. $sf configure -width $w
  158. $dlg draw
  159. }
  160. #--------------------------------------------------------
  161. #
  162. # ::bem::sweepEntry
  163. #
  164. # Create and grid widgets for a sweep dialog entry.
  165. # This creates a checkbutton and three entry widgets for
  166. # start value, end value, and number of iterations.
  167. # the widgets are created with associated textvariables,
  168. # and gridded into the specified frame.
  169. #
  170. #--------------------------------------------------------
  171. set ::bem::BuildCount 0
  172. proc ::bem::sweepEntry { f desc flagvar startvar endvar numvar } {
  173. # Create widgets
  174. set c [incr ::bem::BuildCount]
  175. set estart [entry $f.estart$c -width 10 -textvariable $startvar]
  176. set eend [entry $f.eend$c -width 10 -textvariable $endvar]
  177. set enum [entry $f.enum$c -width 10 -textvariable $numvar]
  178. set cbox [checkbutton $f.cb$c -variable $flagvar -text $desc]
  179. # Set command for enable/disable of this set of fields,
  180. # and set initial state.
  181. $cbox configure \
  182. -command [list ::bem::sweepEntrySelect $flagvar $estart $eend $enum]
  183. ::bem::sweepEntrySelect $flagvar $estart $eend $enum
  184. # Arrange widgets in the parent
  185. grid x $cbox $estart $eend $enum -sticky ew -padx 4 -pady 4
  186. grid $cbox -sticky w
  187. }
  188. #--------------------------------------------------------
  189. #
  190. # ::bem::sweepEntrySelect
  191. #
  192. # Toggles entry widgets normal/disabled for
  193. # the fields on the sweepBEM dialog.
  194. #
  195. #--------------------------------------------------------
  196. proc ::bem::sweepEntrySelect {flagvar estart eend enum} {
  197. upvar $flagvar flag
  198. if { $flag } {
  199. $estart configure -state normal
  200. $eend configure -state normal
  201. $enum configure -state normal
  202. } else {
  203. $estart configure -state disabled
  204. $eend configure -state disabled
  205. $enum configure -state disabled
  206. }
  207. }
  208. #--------------------------------------------------------
  209. # Build the gui interface containing all items that the
  210. # application can sweep.
  211. #
  212. # nodename: name of the cross-section file (without the extension)
  213. # cSegs : number of C segments to mesh
  214. # pSegs : number of P segments to mesh
  215. # doGui : 1 - being run from mmtl.tcl 0 - outside of mmtl.tcl
  216. # parent : widget id or 0
  217. #
  218. #----------------------------------------------------------
  219. proc ::bem::bemRunSweepMMTL { nodename cSegs pSegs {doGui 0} {parent 0} \
  220. {wdgt 0} } {
  221. set ::gui::_nodename $nodename
  222. set ::bem::Csegs $cSegs
  223. set ::bem::Psegs $pSegs
  224. set ::bem::Gui $doGui
  225. set ::bem::Parent $parent
  226. #--------------------------------------------
  227. # Initialize arrays of sweeping parameters.
  228. # Each parameter has a start value, end value
  229. # and number of iterations.
  230. #--------------------------------------------
  231. array unset ::bem::_arrStartLis
  232. array unset ::bem::_arrEndList
  233. array unset ::bem::_arrNumList
  234. #--------------------------------------------
  235. # Dielectric layer parameters are
  236. # thickness and permittivity.
  237. #--------------------------------------------
  238. array unset ::bem::_arrDielThckList
  239. array unset ::bem::_arrDielPrmtList
  240. #--------------------------------------------
  241. # RectangleConductors allow sweeping
  242. # width, height, conductivity and pitch,
  243. # and X and Y offsets.
  244. #--------------------------------------------
  245. array unset ::bem::_arrRectWidthList
  246. array unset ::bem::_arrRectHeightList
  247. array unset ::bem::_arrRectCndctList
  248. array unset ::bem::_arrRectPtchList
  249. array unset ::bem::_arrRectXoffList
  250. array unset ::bem::_arrRectYoffList
  251. #--------------------------------------------
  252. # CircleConductors allow sweeping
  253. # diameter, conductivity and pitch,
  254. # and X and Y offsets.
  255. #--------------------------------------------
  256. array unset ::bem::_arrCircDiamList
  257. array unset ::bem::_arrCircCndctList
  258. array unset ::bem::_arrCircPtchList
  259. array unset ::bem::_arrCircXoffList
  260. array unset ::bem::_arrCircYoffList
  261. #--------------------------------------------
  262. # TrapezoidConductors allow sweeping
  263. # top and bottom width, height, conductivity
  264. # and pitch, and X and Y offsets.
  265. #--------------------------------------------
  266. array unset ::bem::_arrTrapWidthTopList
  267. array unset ::bem::_arrTrapWidthBotList
  268. array unset ::bem::_arrTrapHeightList
  269. array unset ::bem::_arrTrapCndctList
  270. array unset ::bem::_arrTrapPtchList
  271. array unset ::bem::_arrTrapXoffList
  272. array unset ::bem::_arrTrapYoffList
  273. if { [string length $nodename] < 1 } {
  274. _open_existing
  275. }
  276. set ::bem::_doCseg 0
  277. set ::bem::_doPseg 0
  278. set ::bem::_doClngLgt 0
  279. set ::bem::_doRseTme 0
  280. #--------------------------------------------
  281. # Create the sweep dialog
  282. #--------------------------------------------
  283. set ::bem::_sweepParamDialog [Dialog .sweep -title "Sweep Parameters" \
  284. -side bottom -anchor e -default 0 -cancel 1]
  285. $::bem::_sweepParamDialog add -text "Ok"
  286. $::bem::_sweepParamDialog add -text "Cancel"
  287. set ::bem::_sweepFrame [$::bem::_sweepParamDialog getframe]
  288. set _sweepBox [ ::gui::guiCheckbox_create $::bem::_sweepFrame.rb \
  289. "Choose Sweep Parameters"]
  290. pack $_sweepBox -side left -expand true -fill x
  291. #--------------------------------------------
  292. # Add checkbuttons for all possible
  293. # "sweep-able" values
  294. #--------------------------------------------
  295. ::gui::guiCheckbox_add $_sweepBox "C-seg" ::bem::_doCseg
  296. ::gui::guiCheckbox_add $_sweepBox "D-seg" ::bem::_doPseg
  297. ::gui::guiCheckbox_add $_sweepBox "CouplingLength" ::bem::_doClngLgt
  298. ::gui::guiCheckbox_add $_sweepBox "RiseTime" ::bem::_doRseTme
  299. foreach itm [itcl::find objects -class DielectricLayer] {
  300. set ::bem::_arrDielThckList($itm) 0
  301. ::gui::guiCheckbox_add $_sweepBox "$itm thickness" ::bem::_arrDielThckList($itm)
  302. set ::bem::_arrDielPrmtList($itm) 0
  303. ::gui::guiCheckbox_add $_sweepBox "$itm permittivity" ::bem::_arrDielPrmtList($itm)
  304. }
  305. foreach itm [itcl::find objects -class RectangleConductors] {
  306. set ::bem::_arrRectWidthList($itm) 0
  307. ::gui::guiCheckbox_add $_sweepBox "$itm width" ::bem::_arrRectWidthList($itm)
  308. set ::bem::_arrRectHeightList($itm) 0
  309. ::gui::guiCheckbox_add $_sweepBox "$itm height" ::bem::_arrRectHeightList($itm)
  310. set ::bem::_arrRectCndctList($itm) 0
  311. ::gui::guiCheckbox_add $_sweepBox "$itm conductivity" \
  312. ::bem::_arrRectCndctList($itm)
  313. set ::bem::_arrRectPtchList($itm) 0
  314. if { [$itm cget -pitch] > 1 } {
  315. ::gui::guiCheckbox_add $_sweepBox "$itm pitch" ::bem::_arrRectPtchList($itm)
  316. }
  317. set ::bem::_arrRectXoffList($itm) 0
  318. ::gui::guiCheckbox_add $_sweepBox "$itm xOffset" ::bem::_arrRectXoffList($itm)
  319. set ::bem::_arrRectYoffList($itm) 0
  320. ::gui::guiCheckbox_add $_sweepBox "$itm yOffset" ::bem::_arrRectYoffList($itm)
  321. }
  322. foreach itm [itcl::find objects -class CircleConductors] {
  323. set ::bem::_arrCircDiamList($itm) 0
  324. ::gui::guiCheckbox_add $_sweepBox "$itm diameter" ::bem::_arrCircDiamList($itm)
  325. set ::bem::_arrCircCndctList($itm) 0
  326. ::gui::guiCheckbox_add $_sweepBox "$itm conductivity" ::bem::_arrCircCndctList($itm)
  327. set ::bem::_arrCircPtchList($itm) 0
  328. if { [$itm cget -pitch] > 1 } {
  329. ::gui::guiCheckbox_add $_sweepBox "$itm pitch" ::bem::_arrCircPtchList($itm)
  330. }
  331. set ::bem::_arrCircXoffList($itm) 0
  332. ::gui::guiCheckbox_add $_sweepBox "$itm xOffset" ::bem::_arrCircXoffList($itm)
  333. set ::bem::_arrCircYoffList($itm) 0
  334. ::gui::guiCheckbox_add $_sweepBox "$itm yOffset" ::bem::_arrCircYoffList($itm)
  335. }
  336. foreach itm [itcl::find objects -class TrapezoidConductors] {
  337. set ::bem::_arrTrapWidthTopList($itm) 0
  338. ::gui::guiCheckbox_add $_sweepBox "$itm topWidth" ::bem::_arrTrapWidthTopList($itm)
  339. set ::bem::_arrTrapWidthBotList($itm) 0
  340. ::gui::guiCheckbox_add $_sweepBox "$itm botWidth" ::bem::_arrTrapWidthBotList($itm)
  341. set ::bem::_arrTrapHeightList($itm) 0
  342. ::gui::guiCheckbox_add $_sweepBox "$itm height" ::bem::_arrTrapHeightList($itm)
  343. set ::bem::_arrTrapCndctList($itm) 0
  344. ::gui::guiCheckbox_add $_sweepBox "$itm conductivity" \
  345. ::bem::_arrTrapCndctList($itm)
  346. set ::bem::_arrTrapPtchList($itm) 0
  347. if { [$itm cget -pitch] > 1 } {
  348. ::gui::guiCheckbox_add $_sweepBox "$itm pitch" ::bem::_arrTrapPtchList($itm)
  349. }
  350. set ::bem::_arrTrapXoffList($itm) 0
  351. ::gui::guiCheckbox_add $_sweepBox "$itm xOffset" ::bem::_arrTrapXoffList($itm)
  352. set ::bem::_arrTrapYoffList($itm) 0
  353. ::gui::guiCheckbox_add $_sweepBox "$itm yOffset" ::bem::_arrTrapYoffList($itm)
  354. }
  355. set result [$::bem::_sweepParamDialog draw]
  356. destroy $::bem::_sweepParamDialog
  357. if { $result == 0 } {
  358. ::bem::_doSweep
  359. }
  360. }
  361. proc ::bem::_doSweep {} {
  362. set ::bem::_row 1
  363. set ::bem::_col 0
  364. set ::bem::_startcs 0
  365. set ::bem::_endcs 0
  366. set ::bem::_numcs 0
  367. set ::bem::_startps 0
  368. set ::bem::_endps 0
  369. set ::bem::_numps 0
  370. set ::bem::_startcl 0
  371. set ::bem::_endcl 0
  372. set ::bem::_numcl 0
  373. set ::bem::_startrt 0
  374. set ::bem::_endrt 0
  375. set ::bem::_numrt 0
  376. set ::bem::BuildCount 0
  377. set ::bem::_spFrame [toplevel .parameterValues]
  378. wm iconname $::bem::_spFrame "Sweep1"
  379. wm iconify $::bem::_spFrame
  380. if { $::bem::_doCseg } {
  381. set ::bem::_startcs $::bem::Csegs
  382. _buildSweepParameters $::bem::_spFrame "C-Seg" \
  383. "::bem::_startcs" "::bem::_endcs" "::bem::_numcs"
  384. }
  385. if { $::bem::_doPseg } {
  386. set ::bem::_startps $::bem::Psegs
  387. ::bem::_buildSweepParameters $::bem::_spFrame "D-Seg" \
  388. "::bem::_startps" "::bem::_endps" "::bem::_numps"
  389. }
  390. if { $::bem::_doClngLgt } {
  391. set ::bem::_startcl $::Stackup::couplingLength
  392. ::bem::_buildSweepParameters $::bem::_spFrame "Coupling Length" \
  393. "::bem::_startcl" "::bem::_endcl" "::bem::_numcl"
  394. }
  395. if { $::bem::_doRseTme } {
  396. set ::bem::_startrt $::Stackup::riseTime
  397. ::bem::_buildSweepParameters $::bem::_spFrame "Rise Time" \
  398. "::bem::_startrt" "::bem::_endrt" "::bem::_numrt"
  399. }
  400. foreach nme [itcl::find objects -class DielectricLayer] {
  401. if { $::bem::_arrDielThckList($nme) } {
  402. ::bem::_buildSweepEntryFrame $nme T [$nme cget -thickness] \
  403. "$nme Thickness"
  404. }
  405. if { $::bem::_arrDielPrmtList($nme) } {
  406. ::bem::_buildSweepEntryFrame $nme P [$nme cget -permittivity] \
  407. "$nme Permittivity"
  408. }
  409. }
  410. foreach nme [itcl::find objects -class RectangleConductors] {
  411. if { $::bem::_arrRectWidthList($nme) } {
  412. ::bem::_buildSweepEntryFrame $nme RW [$nme cget -width] \
  413. "$nme Width"
  414. }
  415. if { $::bem::_arrRectHeightList($nme) } {
  416. ::bem::_buildSweepEntryFrame $nme RH [$nme cget -height] \
  417. "$nme Height"
  418. }
  419. if { $::bem::_arrRectCndctList($nme) } {
  420. ::bem::_buildSweepEntryFrame $nme RC [$nme cget -conductivity] \
  421. "$nme Conductivity"
  422. }
  423. if { $::bem::_arrRectPtchList($nme) } {
  424. ::bem::_buildSweepEntryFrame $nme RP [$nme cget -pitch] \
  425. "$nme Pitch"
  426. }
  427. if { $::bem::_arrRectXoffList($nme) } {
  428. ::bem::_buildSweepEntryFrame $nme RX [$nme cget -xOffset] \
  429. "$nme xOffset"
  430. }
  431. if { $::bem::_arrRectYoffList($nme) } {
  432. ::bem::_buildSweepEntryFrame $nme RY [$nme cget -yOffset] \
  433. "$nme yOffset"
  434. }
  435. }
  436. foreach nme [itcl::find objects -class CircleConductors] {
  437. if { $::bem::_arrCircDiamList($nme) } {
  438. ::bem::_buildSweepEntryFrame $nme CD \
  439. [$nme cget -diameter] \
  440. "$nme Diameter"
  441. }
  442. if { $::bem::_arrCircCndctList($nme) } {
  443. ::bem::_buildSweepEntryFrame $nme CC [$nme cget -conductivity] \
  444. "$nme Conductivity"
  445. }
  446. if { $::bem::_arrCircPtchList($nme) } {
  447. ::bem::_buildSweepEntryFrame $nme CP [$nme cget -pitch] \
  448. "$nme Pitch"
  449. }
  450. if { $::bem::_arrCircXoffList($nme) } {
  451. ::bem::_buildSweepEntryFrame $nme CX [$nme cget -xOffset] \
  452. "$nme xOffset"
  453. }
  454. if { $::bem::_arrCircYoffList($nme) } {
  455. ::bem::_buildSweepEntryFrame $nme CY [$nme cget -yOffset] \
  456. "$nme yOffset"
  457. }
  458. }
  459. foreach nme [itcl::find objects -class TrapezoidConductors] {
  460. if { $::bem::_arrTrapWidthTopList($nme) } {
  461. ::bem::_buildSweepEntryFrame $nme TWT \
  462. [$nme cget -topWidth] \
  463. "$nme TopWidth"
  464. }
  465. if { $::bem::_arrTrapWidthBotList($nme) } {
  466. ::bem::_buildSweepEntryFrame $nme TWB \
  467. [$nme cget -bottomWidth] \
  468. "$nme BotWidth"
  469. }
  470. if { $::bem::_arrTrapHeightList($nme) } {
  471. ::bem::_buildSweepEntryFrame $nme TH [$nme cget -height] \
  472. "$nme Height"
  473. }
  474. if { $::bem::_arrTrapCndctList($nme) } {
  475. ::bem::_buildSweepEntryFrame $nme TC [$nme cget -conductivity] \
  476. "$nme Conductivity"
  477. }
  478. if { $::bem::_arrTrapPtchList($nme) } {
  479. ::bem::_buildSweepEntryFrame $nme TP [$nme cget -pitch] \
  480. "$nme Pitch"
  481. }
  482. if { $::bem::_arrTrapXoffList($nme) } {
  483. ::bem::_buildSweepEntryFrame $nme TX [$nme cget -xOffset] \
  484. "$nme xOffset"
  485. }
  486. if { $::bem::_arrTrapYoffList($nme) } {
  487. ::bem::_buildSweepEntryFrame $nme TY [$nme cget -yOffset] \
  488. "$nme yOffset"
  489. }
  490. }
  491. set but1 [::gui::guiBuildButton $::bem::_spFrame "OK" \
  492. "::bem::_finishSweep" "Proceed with the requested sweep"]
  493. set but2 [::gui::guiBuildButton $::bem::_spFrame "Cancel" \
  494. "::bem::_cancelBldSweep" "Cancel the sweep"]
  495. grid $but1 $but2 -sticky nw
  496. wm deiconify $::bem::_spFrame
  497. grab $::bem::_spFrame
  498. }
  499. proc ::bem::_buildSweepEntryFrame { nme type value txtStrg } {
  500. set indx [format "%s-$type" $nme]
  501. set ::bem::_arrStartList($indx) $value
  502. set ::bem::_arrEndList($indx) 0
  503. set ::bem::_arrNumList($indx) 0
  504. ::bem::_buildSweepParameters $::bem::_spFrame $txtStrg \
  505. ::bem::_arrStartList($indx) ::bem::_arrEndList($indx) \
  506. ::bem::_arrNumList($indx)
  507. }
  508. proc ::bem::_cancelBldSweep {} {
  509. destroy $::bem::_spFrame
  510. }
  511. proc ::bem::_buildSweepParameters { parent title startVar endVar iterVar } {
  512. incr ::bem::BuildCount
  513. set frme [frame $parent.frme$::bem::BuildCount \
  514. -relief groove -borderwidth 3]
  515. set seglbl [label $frme.seglbl$::bem::BuildCount \
  516. -justify left -text $title]
  517. grid $seglbl -columnspan 2 -sticky w
  518. set startlab [label $frme.startlab -text "Starting Value"]
  519. set startent [entry $frme.startent -textvariable $startVar]
  520. grid $startlab $startent -sticky news -padx 2 -pady 2
  521. set endlab [label $frme.endlab -text "Ending Value"]
  522. set endent [entry $frme.endent -textvariable $endVar]
  523. grid $endlab $endent -sticky news -padx 2 -pady 2
  524. set numlab [label $frme.numlab -text "# Iterations"]
  525. set nument [entry $frme.nument -textvariable $iterVar]
  526. grid $numlab $nument -sticky news -padx 2 -pady 2
  527. grid $frme -row $::bem::_row -column $::bem::_col -sticky new
  528. if { $::bem::_col == 0 } {
  529. set ::bem::_col 1
  530. } else {
  531. incr ::bem::_row
  532. set ::bem::_col 0
  533. }
  534. }
  535. proc ::bem::_finishSweep {} {
  536. set ::bem::_totalLoops 0
  537. set ::bem::_curls 0
  538. set flenme "$::gui::_nodename.sweep_script"
  539. set fp [open $flenme w]
  540. puts $fp "proc _runSweep \{\} \{"
  541. puts $fp " global _nodename"
  542. puts $fp " global _num_c_segs"
  543. puts $fp " global _num_p_segs"
  544. puts $fp " "
  545. puts $fp " foreach { nme vle } \[ array get ::bem::_changesArr \] \{"
  546. puts $fp " unset ::bem::_changesArr(\$nme)"
  547. puts $fp " \}"
  548. puts $fp " set resultsFle \[ open \"$::gui::_nodename.swept_result\" w \] "
  549. puts $fp " set logFle \[ open \"$::gui::_nodename.swept_result_log\" w \] "
  550. if { $::bem::_doCseg } {
  551. puts $fp " # ConductorSegments \
  552. start: $::bem::_startcs end: $::bem::_endcs \
  553. number of iterations: $::bem::_numcs"
  554. if { [_buildSweepScript $fp "" "C-Seg" $::bem::_startcs $::bem::_endcs $::bem::_numcs ""] } {
  555. return
  556. }
  557. }
  558. if { $::bem::_doPseg } {
  559. puts $fp " # DielectricSegments \
  560. start: $::bem::_startps end: $::bem::_endps \
  561. number of iterations: $::bem::_numps"
  562. if { [_buildSweepScript $fp "" "D-Seg" $::bem::_startps $::bem::_endps $::bem::_numps ""] } {
  563. return
  564. }
  565. }
  566. if { $::bem::_doClngLgt } {
  567. puts $fp " # CouplingLength \
  568. start: $::bem::_startcl end: $::bem::_endcl \
  569. number of iterations: $::bem::_numcl"
  570. if { [_buildSweepScript $fp "" "Coupling-length" $::bem::_startcl \
  571. $::bem::_endcl $::bem::_numcl $::units::default(Length)] } {
  572. return
  573. }
  574. }
  575. if { $::bem::_doRseTme } {
  576. puts $fp " # Risetime \
  577. start: $::bem::_startrt end: $::bem::_endrt \
  578. number of iterations: $::bem::_numrt"
  579. if { [_buildSweepScript $fp "" "Risetime" $::bem::_startrt \
  580. $::bem::_endrt $::bem::_numrt $::units::default(Time)] } {
  581. return
  582. }
  583. }
  584. foreach nme [itcl::find objects -class DielectricLayer] {
  585. if { $::bem::_arrDielThckList($nme) } {
  586. puts $fp " # Dielectric thickness "
  587. if { [_addToScript $fp $nme "T" "DielectricLayer" \
  588. "thickness" $::units::default(Length)] } {
  589. return
  590. }
  591. }
  592. if { $::bem::_arrDielPrmtList($nme) } {
  593. puts $fp " # Dielectric permittivity "
  594. if { [_addToScript $fp $nme "P" "DielectricLayer" \
  595. "permittivity" ""] } {
  596. return
  597. }
  598. }
  599. }
  600. foreach nme [itcl::find objects -class RectangleConductors] {
  601. if { $::bem::_arrRectWidthList($nme) } {
  602. set indx [ format "%s-RW" $nme ]
  603. puts $fp " # RectangleConductors $nme \
  604. start: $::bem::_arrStartList($indx) \
  605. end: $::bem::_arrEndList($indx) \
  606. number of iterations: $::bem::_arrNumList($indx)"
  607. if { [_buildSweepScript $fp $nme "width" $::bem::_arrStartList($indx) \
  608. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  609. return
  610. }
  611. }
  612. if { $::bem::_arrRectHeightList($nme) } {
  613. set indx [ format "%s-RH" $nme ]
  614. puts $fp " # RectangleConductors $nme \
  615. start: $::bem::_arrStartList($indx) \
  616. end: $::bem::_arrEndList($indx) \
  617. number of iterations: $::bem::_arrNumList($indx)"
  618. if { [_buildSweepScript $fp $nme "height" $::bem::_arrStartList($indx) \
  619. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  620. return
  621. }
  622. }
  623. if { $::bem::_arrRectCndctList($nme) } {
  624. set indx [ format "%s-RC" $nme ]
  625. puts $fp " # RectangleConductors $nme \
  626. start: $::bem::_arrStartList($indx) \
  627. end: $::bem::_arrEndList($indx) \
  628. number of iterations: $::bem::_arrNumList($indx)"
  629. if { [_buildSweepScript $fp $nme "conductivity" \
  630. $::bem::_arrStartList($indx) \
  631. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) "siemens/meter"] } {
  632. return
  633. }
  634. }
  635. if { $::bem::_arrRectPtchList($nme) } {
  636. set indx [ format "%s-RP" $nme ]
  637. puts $fp " # RectangleConductors $nme \
  638. start: $::bem::_arrStartList($indx) \
  639. end: $::bem::_arrEndList($indx) \
  640. number of iterations: $::bem::_arrNumList($indx)"
  641. if { [_buildSweepScript $fp $nme "pitch" $::bem::_arrStartList($indx) \
  642. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  643. return
  644. }
  645. }
  646. if { $::bem::_arrRectXoffList($nme) } {
  647. set indx [ format "%s-RX" $nme ]
  648. puts $fp " # RectangleConductors $nme \
  649. start: $::bem::_arrStartList($indx) \
  650. end: $::bem::_arrEndList($indx) \
  651. number of iterations: $::bem::_arrNumList($indx)"
  652. if { [_buildSweepScript $fp $nme "xOffset" $::bem::_arrStartList($indx) \
  653. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  654. return
  655. }
  656. }
  657. if { $::bem::_arrRectYoffList($nme) } {
  658. set indx [ format "%s-RY" $nme ]
  659. puts $fp " # RectangleConductors $nme \
  660. start: $::bem::_arrStartList($indx) \
  661. end: $::bem::_arrEndList($indx) \
  662. number of iterations: $::bem::_arrNumList($indx)"
  663. if { [_buildSweepScript $fp $nme "yOffset" $::bem::_arrStartList($indx) \
  664. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  665. return
  666. }
  667. }
  668. }
  669. foreach nme [itcl::find objects -class CircleConductors] {
  670. if { $::bem::_arrCircDiamList($nme) } {
  671. set indx [ format "%s-CD" $nme ]
  672. puts $fp " # CircleConductors $nme \
  673. start: $::bem::_arrStartList($indx) \
  674. end: $::bem::_arrEndList($indx) \
  675. number of iterations: $::bem::_arrNumList($indx)"
  676. if { [_buildSweepScript $fp $nme "diameter" $::bem::_arrStartList($indx) \
  677. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  678. return
  679. }
  680. }
  681. if { $::bem::_arrCircCndctList($nme) } {
  682. set indx [ format "%s-CC" $nme ]
  683. puts $fp " # CircleConductors $nme \
  684. start: $::bem::_arrStartList($indx) \
  685. end: $::bem::_arrEndList($indx) \
  686. number of iterations: $::bem::_arrNumList($indx)"
  687. if { [_buildSweepScript $fp $nme "conductivity" \
  688. $::bem::_arrStartList($indx) \
  689. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) "siemens/meter"] } {
  690. return
  691. }
  692. }
  693. if { $::bem::_arrCircPtchList($nme) } {
  694. set indx [ format "%s-CP" $nme ]
  695. puts $fp " # CircleConductors $nme \
  696. start: $::bem::_arrStartList($indx) \
  697. end: $::bem::_arrEndList($indx) \
  698. number of iterations: $::bem::_arrNumList($indx)"
  699. if { [_buildSweepScript $fp $nme "pitch" $::bem::_arrStartList($indx) \
  700. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  701. return
  702. }
  703. }
  704. if { $::bem::_arrCircXoffList($nme) } {
  705. set indx [ format "%s-CX" $nme ]
  706. puts $fp " # CircleConductors $nme \
  707. start: $::bem::_arrStartList($indx) \
  708. end: $::bem::_arrEndList($indx) \
  709. number of iterations: $::bem::_arrNumList($indx)"
  710. if { [_buildSweepScript $fp $nme "xOffset" $::bem::_arrStartList($indx) \
  711. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  712. return
  713. }
  714. }
  715. if { $::bem::_arrCircYoffList($nme) } {
  716. set indx [ format "%s-CY" $nme ]
  717. puts $fp " # CircleConductors $nme \
  718. start: $::bem::_arrStartList($indx) \
  719. end: $::bem::_arrEndList($indx) \
  720. number of iterations: $::bem::_arrNumList($indx)"
  721. if { [_buildSweepScript $fp $nme "yOffset" $::bem::_arrStartList($indx) \
  722. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  723. return
  724. }
  725. }
  726. }
  727. foreach nme [itcl::find objects -class TrapezoidConductors] {
  728. if { $::bem::_arrTrapWidthTopList($nme) } {
  729. set indx [ format "%s-TWT" $nme ]
  730. puts $fp " # TrapezoidConductors $nme \
  731. start: $::bem::_arrStartList($indx) \
  732. end: $::bem::_arrEndList($indx) \
  733. number of iterations: $::bem::_arrNumList($indx)"
  734. if { [_buildSweepScript $fp $nme "topWidth" $::bem::_arrStartList($indx) \
  735. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  736. return
  737. }
  738. }
  739. if { $::bem::_arrTrapWidthBotList($nme) } {
  740. set indx [ format "%s-TWB" $nme ]
  741. puts $fp "\# TrapezoidConductors $nme \
  742. start: $::bem::_arrStartList($indx) \
  743. end: $::bem::_arrEndList($indx) \
  744. number of iterations: $::bem::_arrNumList($indx)"
  745. if { [_buildSweepScript $fp $nme "bottomWidth" $::bem::_arrStartList($indx) \
  746. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  747. return
  748. }
  749. }
  750. if { $::bem::_arrTrapHeightList($nme) } {
  751. set indx [ format "%s-TH" $nme ]
  752. puts $fp "\# TrapezoidConductors $nme \
  753. start: $::bem::_arrStartList($indx) \
  754. end: $::bem::_arrEndList($indx) \
  755. number of iterations: $::bem::_arrNumList($indx)"
  756. if { [_buildSweepScript $fp $nme "height" $::bem::_arrStartList($indx) \
  757. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  758. return
  759. }
  760. }
  761. if { $::bem::_arrTrapCndctList($nme) } {
  762. set indx [ format "%s-TC" $nme ]
  763. puts $fp "\# TrapezoidConductors $nme \
  764. start: $::bem::_arrStartList($indx) \
  765. end: $::bem::_arrEndList($indx) \
  766. number of iterations: $::bem::_arrNumList($indx)"
  767. if { [_buildSweepScript $fp $nme "conductivity" \
  768. $::bem::_arrStartList($indx) \
  769. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) "siemens/meter"] } {
  770. return
  771. }
  772. }
  773. if { $::bem::_arrTrapPtchList($nme) } {
  774. set indx [ format "%s-TP" $nme ]
  775. puts $fp "\# TrapezoidConductors $nme \
  776. start: $::bem::_arrStartList($indx) \
  777. end: $::bem::_arrEndList($indx) \
  778. number of iterations: $::bem::_arrNumList($indx)"
  779. if { [_buildSweepScript $fp $nme "pitch" $::bem::_arrStartList($indx) \
  780. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  781. return
  782. }
  783. }
  784. if { $::bem::_arrTrapXoffList($nme) } {
  785. set indx [ format "%s-TX" $nme ]
  786. puts $fp " # TraezpodConductors $nme \
  787. start: $::bem::_arrStartList($indx) \
  788. end: $::bem::_arrEndList($indx) \
  789. number of iterations: $::bem::_arrNumList($indx)"
  790. if { [_buildSweepScript $fp $nme "xOffset" $::bem::_arrStartList($indx) \
  791. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  792. return
  793. }
  794. }
  795. if { $::bem::_arrTrapYoffList($nme) } {
  796. set indx [ format "%s-TY" $nme ]
  797. puts $fp " # TrapezoidConductors $nme \
  798. start: $::bem::_arrStartList($indx) \
  799. end: $::bem::_arrEndList($indx) \
  800. number of iterations: $::bem::_arrNumList($indx)"
  801. if { [_buildSweepScript $fp $nme "yOffset" $::bem::_arrStartList($indx) \
  802. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $::units::default(Length)] } {
  803. return
  804. }
  805. }
  806. }
  807. ::bem::_finishSweepFile $fp
  808. close $fp
  809. ::bem::_runTheSimulations sweep_script _runSweep \
  810. "The generated script will run the\
  811. simulation $::bem::_totalLoops times."
  812. }
  813. proc ::bem::_addToScript { fp nme ext type txt units } {
  814. set indx [ format "%s-%s" $nme $ext]
  815. puts $fp " \# $type $nme ($txt) \
  816. start: $::bem::_arrStartList($indx) \
  817. end: $::bem::_arrEndList($indx) \
  818. number of iterations: $::bem::_arrNumList($indx)"
  819. if { [_buildSweepScript $fp $nme $txt $::bem::_arrStartList($indx) \
  820. $::bem::_arrEndList($indx) $::bem::_arrNumList($indx) $units ] } {
  821. close $fp
  822. return 1
  823. }
  824. return 0
  825. }
  826. proc ::bem::_buildSweepScript { fp nme value strt end num units } {
  827. global env
  828. #---------------------------------------------------------
  829. # Make certain that the number of iterations is an interger
  830. # number.
  831. #---------------------------------------------------------
  832. if { ([scan $num {%d} numLoops] != 1) || \
  833. ($numLoops < 1) } {
  834. ::gui::guiPopupWarning \
  835. "The number of iterations must be an INTEGER > 0."
  836. return 1
  837. }
  838. if { ($num != $numLoops) || ($numLoops < 1 ) } {
  839. ::gui::guiPopupWarning \
  840. "The number of iterations must be an INTEGER > 0."
  841. return 1
  842. }
  843. #---------------------------------------------------------
  844. # Save the total number of loops for running nmmtl.
  845. #---------------------------------------------------------
  846. if { $::bem::_totalLoops == 0 } {
  847. set ::bem::_totalLoops $numLoops
  848. } else {
  849. set ::bem::_totalLoops [expr {$::bem::_totalLoops * $numLoops}]
  850. }
  851. puts "____ # iterations: $::bem::_totalLoops ___"
  852. incr ::bem::_curls
  853. # Convert from/to into unit-less number
  854. # Adding default units, if necessary
  855. if { [string is double $strt] } {
  856. append strt $units
  857. }
  858. set from [units::convert $strt $units]
  859. if { [string is double $end] } {
  860. append end $units
  861. }
  862. set to [units::convert $end $units]
  863. # Check for valid length units
  864. if { ! [catch {units::convert $units "meter"}] } {
  865. if { $from < 0 } {
  866. ::gui::guiPopupWarning \
  867. "The starting dimension must be greater than 0."
  868. return 1
  869. }
  870. if { $to < 0 } {
  871. ::gui::guiPopupWarning \
  872. "The ending dimension must be greater than 0."
  873. return 1
  874. }
  875. }
  876. #---------------------------------------------------------
  877. # If the number of iterations is 1, set the increment to 0.
  878. #---------------------------------------------------------
  879. if { $numLoops == 1 } {
  880. set incrt 0
  881. } else {
  882. set incrt [expr { double($to - $from) / ($numLoops - 1)} ]
  883. }
  884. #---------------------------------------------------------
  885. # Create the for loop.
  886. #---------------------------------------------------------
  887. puts $fp "puts \"----------------------------------------\""
  888. puts $fp " set val$::bem::_curls $from"
  889. set strg [ format " for { set i$::bem::_curls 0 } \
  890. { \$i$::bem::_curls < %d } { incr i$::bem::_curls } \{ " \
  891. $numLoops ]
  892. puts $fp $strg
  893. #---------------------------------------------------------
  894. # Change the value affected by the for loop.
  895. #---------------------------------------------------------
  896. if { [string length $nme] > 0 } {
  897. puts $fp " $nme configure -$value \$val$::bem::_curls "
  898. puts $fp " set ::bem::_changesArr\($nme-$value) \"$nme $value = \$val$::bem::_curls\""
  899. } else {
  900. if { [string compare $value "C-Seg"] == 0 } {
  901. puts $fp " set ::bem::Csegs \$val$::bem::_curls"
  902. puts $fp " set ::bem::_changesArr\(CSEG) \"CSEG = \$val$::bem::_curls\""
  903. }
  904. if { [string compare $value "D-Seg"] == 0 } {
  905. puts $fp " set ::bem::Psegs \$val$::bem::_curls"
  906. puts $fp " set ::bem::_changesArr\(PSEG) \"DSEG = \$val$::bem::_curls\""
  907. }
  908. if { [string compare $value "Coupling-length"] == 0 } {
  909. puts $fp " set Stackup\:\:couplingLength \$val$::bem::_curls"
  910. puts $fp " set ::bem::_changesArr\(CL) \"Cplg-lgt = \$val$::bem::_curls\""
  911. }
  912. if { [string compare $value "Risetime"] == 0 } {
  913. puts $fp " set Stackup\:\:riseTime \$val$::bem::_curls"
  914. puts $fp " set ::bem::_changesArr\(RT) \"Risetime = \$val$::bem::_curls\""
  915. }
  916. }
  917. puts $fp " set val$::bem::_curls \[ expr \{ \$val$::bem::_curls + $incrt \}\]"
  918. return 0
  919. }
  920. proc ::bem::_finishSweepFile { fp } {
  921. global env
  922. puts $fp " puts \$resultsFle \"\""
  923. puts $fp " puts \$resultsFle \"_______________________________________________________\""
  924. puts $fp " puts \$logFle \"_______________________________________________________\""
  925. puts $fp " puts \$resultsFle \"\""
  926. puts $fp " puts \$logFle \"\""
  927. puts $fp " foreach itm \$Stackup\:\:structureList \{"
  928. puts $fp " set lgt \[string length \$itm]"
  929. puts $fp " set nme \[string range \$itm 2 \$lgt]"
  930. puts $fp " if \{ \[\$nme isa GroundPlane\] \} \{"
  931. puts $fp " ::bem::bemPutGroundPlaneToFile \$nme \$resultsFle"
  932. puts $fp " ::bem::bemPutGroundPlaneToFile \$nme \$logFle"
  933. puts $fp " \}"
  934. puts $fp " if \{ \[\$nme isa DielectricLayer\] \} \{"
  935. puts $fp " ::bem::bemPutDielectricLayerToFile \$nme \$resultsFle"
  936. puts $fp " ::bem::bemPutDielectricLayerToFile \$nme \$logFle"
  937. puts $fp " \}"
  938. puts $fp " if \{ \[\$nme isa RectangleConductors\] \} \{"
  939. puts $fp " ::bem::bemPutRectangleConductorsToFile \$nme \$resultsFle"
  940. puts $fp " ::bem::bemPutRectangleConductorsToFile \$nme \$logFle"
  941. puts $fp " \}"
  942. puts $fp " if \{ \[\$nme isa CircleConductors\] \} \{"
  943. puts $fp " ::bem::bemPutCircleConductorsToFile \$nme \$resultsFle"
  944. puts $fp " ::bem::bemPutCircleConductorsToFile \$nme \$logFle"
  945. puts $fp " \}"
  946. puts $fp " if \{ \[\$nme isa TrapezoidConductors\] \} \{"
  947. puts $fp " ::bem::bemPutTrapezoidConductorsToFile \$nme \$resultsFle"
  948. puts $fp " ::bem::bemPutTrapezoidConductorsToFile \$nme \$logFle"
  949. puts $fp " \}"
  950. puts $fp " \}"
  951. puts $fp " ::gui::_replaceNamedValues"
  952. set workingNode [format {%sTMP} $::gui::_nodename]
  953. puts $fp " ::csdl::csdlWriteTCL \"$workingNode.xsctn\" \"$::gui::_title\" \
  954. $::bem::Csegs $::bem::Psegs"
  955. set cmdName [auto_execok bem]
  956. puts $fp " set cmmnd {$cmdName \
  957. \"$workingNode\" \$::bem::Csegs \$::bem::Psegs } "
  958. set strg [ format " set msg \[catch \{ eval exec \$cmmnd \} \
  959. result]" ]
  960. puts $fp $strg
  961. puts $fp " set fin \[open \"$workingNode.result\" r\]"
  962. puts $fp " set results \[read \$fin\]"
  963. puts $fp " puts \$resultsFle \$results"
  964. puts $fp " close \$fin"
  965. puts $fp " foreach { nme vle } \[ array get ::bem::_changesArr \] \{"
  966. puts $fp " puts \$vle"
  967. puts $fp " \}"
  968. puts $fp " set done \[::bem::bemParseSweptResults \$results \]"
  969. puts $fp " if \{ \$done > 1 \} \{"
  970. puts $fp " close \$logFle"
  971. puts $fp " close \$resultsFle"
  972. puts $fp " return"
  973. puts $fp " \}"
  974. puts $fp " puts \$resultsFle \"\""
  975. puts $fp " puts \$logFle \"\""
  976. puts $fp " puts \"____________________________________________________\""
  977. puts $fp " puts \$logFle \$result"
  978. for { set i 0 } { $i < $::bem::_curls } { incr i } {
  979. set strg " \} "
  980. puts $fp $strg
  981. }
  982. puts $fp " close \$logFle"
  983. puts $fp " close \$resultsFle"
  984. set strg " \}"
  985. puts $fp $strg
  986. }
  987. proc ::bem::bemParseSweptResults { results} {
  988. set indx [string first "Asymmetry Ratios:" $results]
  989. set newstrg2 [string range $results $indx [string length $results] ]
  990. set indx1 [string first "Asymmetry ratio for" $newstrg2 ]
  991. set newstrg [string range $newstrg2 [expr { $indx1 + 42 }] \
  992. [string length $newstrg2]]
  993. set indx2 [string first "*******" $newstrg2]
  994. set tmp [string range $newstrg2 $indx2 [expr { $indx2 + 150 }] ]
  995. set indx [string first "%" $newstrg]
  996. set maxx [ string range $newstrg 0 $indx ]
  997. set newstrg2 [string range $newstrg [expr {$indx + 7 }] \
  998. [expr { $indx + 100 }] ]
  999. set indx [string first "%" $newstrg2]
  1000. set average [string range $newstrg2 0 $indx ]
  1001. set indx [string first Impedance $results]
  1002. set newstrg [string range $results $indx [string length $results]]
  1003. while { 1 } {
  1004. set indx [string first "Signal L" $newstrg]
  1005. set stp [string first "Effective Dielectric" $newstrg]
  1006. if { $indx > $stp } {
  1007. break
  1008. }
  1009. set newstrg [string range $newstrg [expr { $indx + 12 }] \
  1010. [string length $newstrg]]
  1011. set indx [string first "=" $newstrg]
  1012. set nme [string range $newstrg 0 [ expr {$indx - 1}] ]
  1013. set newstrg [string range $newstrg $indx [string length $newstrg]]
  1014. if { [scan $newstrg {= %g} impedance] < 1 } {
  1015. puts stderr "**************************************************"
  1016. puts stderr "Cannot continue because the\
  1017. impedance value for $nme is set to \"nan\""
  1018. puts stderr "**************************************************"
  1019. return 1
  1020. }
  1021. puts "$nme Impedance = $impedance"
  1022. }
  1023. if { $indx1 > $indx2 } {
  1024. puts "** Asymmetry ratio for inductance matrix:"
  1025. puts "$maxx (max), $average (average) **"
  1026. }
  1027. return -1
  1028. }