Escolar Documentos
Profissional Documentos
Cultura Documentos
This document is a self-descriptive tutorial of a problem analysis report creation in MS Word. Time-Harmonic Magnetic problem of a shielded conductor is examined. VB macros control !uic"#ield$ change the model parameters and automatically generate tables and graphs for results presentation in the report. This example is compatible %ith both Students and &rofessional versions of !uic"#ield '.( and higher.
Student
&reface............................................................................................................, Model description..........................................................................................#irst step. !uic"#ield problem creation.......................................................' Second step. /eometrical model dra%ing....................................................0 Third step. Mesh building and geometrical ob1ects labeling........................2 #ourth step. 3abels creation and definition................................................(( #ifth step. &roblem solving and results vie%ing.........................................(+ Sixth step. &roblem parameters iteration....................................................(4esult tables.................................................................................................(0 Bonus Step. #ield pictures and graphs........................................................+5 4esulting field pictures................................................................................++ 4esult graphs................................................................................................+,
Preface.
This example describes the step-by-step process of creation Microsoft Word document interacting %ith !uic"#ield server and obtaining the results of field analysis. :t is divided in several steps. <ach step ends by a button. By pressing this button you may see ho% the 1ust %ritten code %or"s. This example is fully compatible %ith Students and &rofessional versions of !uic"#ield '.( and higher. #ree Students !uic"#ield may be do%nloaded from !uic"#ield Support site %%%.=uic"field.com. To display the graphs you should have Microsoft /raph installed. Microsoft /raph is included into any Microsoft 6ffice suite. Main content of this document is in the macros therefore macros should be enabled. >ou have to enable running macros in the menu Tools -? Macro -? Security -? Security 3evel. :f the settings %ere set to @HighA you may need to change the Security level Medium or 3o%$ then close the document and open it again.
#or more information about changing the security level %ith MS Word please refer to Microsoft 6ffice Help$ the topic B&rotection from documents that might contain virusesB.
Model description.
)opper conductor %ith round cross-section + mm diameter is placed to the origin of coordinates. :t carries electric current %ith variable fre=uency and amplitude$ but as a default %e %ill assume '5 H7 and total current (55 mperes. )ylindrical shield %ith internal radius - mm surrounds the conductor. We %ill analy7e dependence of the electric field parameters from the shield thic"ness in the range 5.' mm to '.' mm$ and its material electrical conductivity and magnetic permeability. We %ill also compare results for shield %ith shortcircuited ends C7ero voltageD$ open ends C7ero total currentD and %ithout shield. To measure the field characteristics %e %ill use the tester E steel rod %ith ( mm radius. 9istance bet%een the centers of tester and conductor is (+ mm. We %ill measure the follo%ing values. + Tester voltage + #lux density + Foule heat density in the conductor and in the shield To measure the voltage and flux density %e %ill use the point %ith coordinates C5.5((+$ 5D in the vicinity of the tester surface. The model is surrounded by the cylindrical boundary %ith radius (5 cm and 7ero 9irichlet boundary condition C G5D. Space bet%een conductor$ shield and tester is filled by air. The physical setup corresponds to Time-Harmonic Magnetic formulation of !uic"#ield. :f you use Students !uic"#ield it is recommended to restrict the finite-element mesh si7e. #or doing that you should set manual mesh steps. at the outer shield boundary E + mm$ at the outer tester surface E( mm$ at the external problem boundary - ' cm. )entral part of this model setup is sho%n in the picture above.
'
Setting a reference to QuickField Object Library #irst of all you should add a reference to !uic"#ield 6b1ect 3ibrary. )hoose Tools -? 4eferences and chec" @!uic"#ield '.+ 6b1ect 3ibraryA in the dialog displayed. bsence of such a string in the list means that !uic"#ield is not properly installed on your computer. QuickField starting This simple code starts !uic"#ield server and displays its %indo%s.
Dim QF As Ne QuickField!A""lication QF!#ain$indo !%isible & 'rue
Problems and models creation )reate ne% problem and model$ and chec" %hether are they created.
Dim Dim Set Set Prb #dl Prb #dl As QuickField!Problem As QuickField!#odel & QF!Problems!Add & QF!#odels!Add
:f you clic" the button t%ice %ithout closing !uic"#ield then t%o examples of problems and models %ill be created. To avoid this you should close all open !uic"#ield documents prior to creation of ne% ones. #ollo%ing strings do that.
QF!Problems!Close QF!#odels!Close
Problem properties definition 8o% %e should initiali7e problem properties and save problem file. &lease$ ta"e into account that all files %ill be stored in the same folder %here this document is located. lternatively you may define the full path. :n this case you %ill need to use the full name path in the problem properties definition and then saving the model and data file.
( De)ine "roblem "arameters Prb!Class & *)PlaneParallel Prb!Problem'+"e & *)'ime,armonic#a-netics Prb!Fre*uenc+ & ./ Prb!Coordinates & *)Cartesian Prb!0en-t12nits & *)#eters Prb!3e)erencedFile(*)#odelFile) & Pat1 4 56Conduct!mod5 Prb!3e)erencedFile(*)DataFile) & Pat1 4 56Conduct!d1e5 ( Save t1e "roblem Prb!SaveAs Pat1 4 56Conduct!"bm5
Here %e set the problem type as &lane-&arallel Time-Harmonic Magnetics in the )artesian coordinate system and ( meter as a length unit. )urrent fre=uency %ill be constant no%$ and %e have set it to '5 H7. The code for problem creation should be copied to VB procedure CreateProblem for using in the follo%ing steps of this example. :t is more convenient to set QF$ Prb and #dl as global variables. #irst Step
3ast t%o strings add t%o arcs of ,.(-(J each$ i.e. dra% a circle %ith 5.55+-meter radius. rguments of functions AddEd-e are the ob1ects of Point class. )orrect %ays of getting these ob1ects are A""lication ob1ect methods Point78 or Point3A. 9o not forget to mention A""lication ob1ect CQF!D %hile using its methods. 9ra%ing procedures for internal and external surfaces of shield$ tester and external boundary are similar to described above.
( Dra S1ield #dl!S1a"es!AddEd-e QF!Point78(/9 /!//=)9 _ QF!Point78(/9 ;/!//=)9 <!1=1> #dl!S1a"es!AddEd-e QF!Point78(/9 ;/!//=)9 _ QF!Point78(/9 /!//=)9 <!1=1> #dl!S1a"es!AddEd-e QF!Point78(/9 /!//.)9 _ QF!Point78(/9 ;/!//.)9 <!1=1> #dl!S1a"es!AddEd-e QF!Point78(/9 ;/!//.)9 _ QF!Point78(/9 /!//.)9 <!1=1> ( Dra 'ester #dl!S1a"es!AddEd-e QF!Point78(/!/1:9 /!//1)9 _ QF!Point78(/!/1:9 ;/!//1)9 <!1=1> #dl!S1a"es!AddEd-e QF!Point78(/!/1:9 ;/!//1)9 _ QF!Point78(/!/1:9 /!//1)9 <!1=1> ( Dra Boundar+ #dl!S1a"es!AddEd-e QF!Point78(/9 /!1)9 _ QF!Point78(/9 ;/!1)9 <!1=1> #dl!S1a"es!AddEd-e QF!Point78(/9 ;/!1)9 _ QF!Point78(/9 /!1)9 <!1=1>
odel !indo! scale setting To see the resulting model you need to display the model %indo%. :t is also possible to maximi7e this %indo%.
Dim $in As QuickField!#odel$indo ( S1o and ma?imi@e model indo Set $in & #dl!$indo s(1) $in!$indo State & *)#a?imi@ed Method Aoom controls the scale of the model display. &lease$ ta"e into account that class $indo doesnHt have Aoom method$ so the ob1ect $in should be an instance of #odel$indo class.
We are interested in analysis not the full model$ but only its central part %ith conductor and tester. )onvenient level of scaling could be defined by the parameters of the Aoom method$ or alternatively by call %ithout parameters$ but before the addition of the external boundary. 4espectively $in should be defined and initiali7ed before this point.
( Set "ro"erl+ scale $in!Aoom
ActiveField Conductor Sample odel file sa"ing Model file should be saved.
#dl!SaveAs Pat1 4 56Conductor!mod5
fter each step of this document you can see a button launching the code created at this step. #or example$ the button after this second step corresponds to the follo%ing procedure.
Private Sub CommandButton:_Click() CreateProblem Dra #odel End Sub
:f you create your o%n document according to our instructions then instead of adding ne% buttons you may edit the code of existing one. Second Step
:t is possible to set the steps of discreti7ation for edges or bloc"s instead of vertices. :n this case the code %ill be little bit shorter. esh generation 8o% Students version is able to build the mesh according to its restrictions.
( Build mes1 #dl!S1a"es!Build#es1
3ast operation re=uired is label assignment to those bloc"s$ vertices and edges$ %hich should have physical properties defined. Shapes labeling ll the bloc"s should be labeled.
#dl!S1a"es!Blocks!Nearest(QF!Point78(/9 /))!0abel & _ 5Conductor5 #dl!S1a"es!Blocks!Nearest(QF!Point78(/9 /!//<))!0abel & 5Air5 #dl!S1a"es!Blocks!Nearest(QF!Point78(/9 /!//=.))!0abel & _ 5S1ield5 #dl!S1a"es!Blocks!Nearest(QF!Point78(/9 /!/1))!0abel & 5Air5 #dl!S1a"es!Blocks!Nearest(QF!Point78(/!/1:9 /))!0abel & _ 5'ester5
T%o edges forming the external boundary should be labeled to set the 7ero 9irichlet boundary condition.
#dl!S1a"es!Ed-es!Nearest(QF!Point78(/!19 /))!0abel & 5Bound5 #dl!S1a"es!Ed-es!Nearest(QF!Point78(;/!19 /))!0abel & 5Bound5
ActiveField Conductor Sample :t is possible no% to save the model Cthe name %as assigned to it at the previous stepD.
#dl!Save
(5
Third Step
((
%efinition of block physical data dditional variables are re=uired to modify material data.
Dim 0ab As QuickField!0abel Dim 0aBl,E As QuickField!0abelBlock,E Dim 0aEd,E As QuickField!0abelEd-e,E
%efinition of edge properties The follo%ing code is related to the external boundary edges.
( De)ine Bound ed-e "ro"erties Set 0ab & Data!0abels(*)Ed-e)(5Bound5) Set 0aEd,E & 0ab!Content 0aEd,E!Diric1let & / 0ab!Content & 0aEd,E
#ourth Step
(+
indo
Field picture "ie!ing #irst thing %e should do is to set the field picture display parameters. Aoom method parameters are the coordinates of the rectangle %e are interested in$ and chosen %ay of presentation is the color map of potential. The last operator is needed to apply the defined parameters to %indo% $in.
Dim $in As QuickField!Field$indo Dim PS As QuickField!FieldPicture ( AdDust "ost"rocessor indo scale Set $in & Prb!3esult!$indo s(1) $in!Aoom QF!Point78(;/!//>9 ;/!//.)9 _ QF!Point78(/!/1<9 /!//.) ( C1an-e "ost"rocessor indo "ro"erties Set PS & $in!PictureSettin-s PS!Color#a" & *)%olta-e PS!E*uilines & False $in!PictureSettin-s & PS
Local "alues calculation These variables are for storing of calculated voltage$ flux density and po%er.
Dim % As Double9 B As Double9 P As Double
Then %e may chec" local parameters in the vicinity of the tester surface. 6b1ect of FieldPoint,E class related to some point should be declared. 3ocal field characteristics may be obtained from this ob1ect properties.
Dim FP As QuickField!FieldPoint,E Set FP & Prb!3esult!Eet0ocal%alues(QF!Point78(/!/11:9 /)) % & FP!ElectroPotential!3 B & FP!Flu?Densit+!3#S
&ntegral "alues calculation We also need to "no% the po%er losses in the shield and conductor. These are integral characteristics. )ontour should be defined to calculate any integrals. The corresponding ob1ect of )ontour class may be obtained through postprocessor %indo% ob1ect. We should clear this contour first and then add bloc"s of conductor and shield to it. Then %e may calculate integral values Ctype *)Cnt_Po erD along this contour.
(,
'esult display t the next step %e %ill insert calculated values into this document. Here %e display the calculated values by simple Message Box.
#s-Bo? 5Potential & 5 4 Format(%9 5/!/////5) 4 5 %5 4 vbCr0) 4 _ 5Flu? densit+ & 5 4 Format(B9 5/!/////5) 4 5 '5 _ 4 vbCr0) 4 _ 5S1ield t1ickness & 1 mm5 4 vbCr0) 4 _ 5Foule 1eat & 5 4 Format(P9 5/!///5) 4 5 $59 9 _ 5Conductor tester5
(-
Parameter accepting #ollo%ing simple code accepts the values entered in the <dit Boxes above.
Private Sub EetParameters() Dim C As Double9 ) As Double Dim 'B As 'e?tBo? ( Eet current value Set 'B & 'e?tBo?1 C) CsNumeric('B!%alue) '1en C & CDbl('B!%alue) Else C & 1// End C) ( Eet )re*uenc+ value Set 'B & 'e?tBo?: C) CsNumeric('B!%alue) '1en ) & CDbl('B!%alue) Else ) & ./ End C) End Sub
Preparations to iteration 4esults %ill be displayed in tables. )olumns %ill correspond to the cases of short-circuit shield$ open end shield and absence of the shield. #irst group of tables sho%s the field dependence upon the thic"ness of copper and steel shields$ next group of tables is related to variable conductivity of the shield %ith fixed si7e$ and the last group of tables is related to variable magnetic permeability of the shield %ith fixed si7e. We %ill observe three parameters E voltage in the tester Csteel rod at some distance from the conductor %ith currentD beyond the shield$ flux density in some fixed point of the tester and density of Foule losses in the conductor and screen Closses in the tester may be neglectedD. There %ere no parameters used in the previous steps. ThatHs %hy %e may copy procedures CreateProblem$ Dra #odel$ #es1And0abel$ De)ineData9 SolveAndEet3esult and name ne% procedures respectively.
Private Private Private Private CreateProblem>() Dra #odel>() #es1And0abel>() De)ineData>(G"tional G"tional G"tional Private Sub SolveAndEet3esult>(% P Sub Sub Sub Sub
G"enEnd As Boolean & False9 _ Cond As Double & H//////9 _ Perm As Double & 1///) As Double9 B As Double9 _ As Double)
('
(. :n CreateProblem> the string displaying the main menu of !uic"#ield should be removed. +. :n EetParameters local variables ) and C should be converted to global ones$ and fre=uency in CreateProblem> should be set to ) instead of '5 H7. ,. )losing of all old models should be transferred from CreateProblem> into Dra #odel>. -. The code of closing postprocessor %indo% Cif it is openD should be added to
Dra #odel>I C) Not Prb!3esult Cs Not1in- '1en Prb!3esult!Close
'. The code of %indo% display and scale setting should be removed from Dra #odel>. J. <xternal shield radius should be set e=ual to (/!//= J 0) instead of /!//. there 0 is the shield thic"ness.
!!! #dl!S1a"es!AddEd-e QF!Point78(/9 /!//= J 0)9 _ QF!Point78(/9 ;(/!//= J 0))9 <!1=1> #dl!S1a"es!AddEd-e QF!Point78(/9 ;(/!//= J 0))9 _ QF!Point78(/9 /!//= J 0)9 <!1=1>
!!!
2.
(5. The code for changing of the postprocessor %indo% settings in the procedure SolveAndEet3esult> is no longer needed and may be deleted. 'esult placing into tables 8o% %e have to iterate shield parameters and insert results into the tables. :t is more convenient to prepare tables beforehand than create them in VB code. :n this
(J
example the tables are already prepared$ and you can see them in 4esult tables section. &rocedure Save%alues inserts the results of one solved problem into the tables. <.g. if 'able & :$ 3o & =$ Col & <$ then %9 B and into P %ill be inserted to the cell C-$ ,D of tables -$ ' and J respectively
Private Sub Save%alues('able As Cnte-er9 _ 3o As Cnte-er9 Col As Cnte-er9 _ % As Double9 B As Double9 P As Double) 'ables(('able ; 1) L < J 1)!Cell(3o 9 Col)!Select Selection!'e?t & Format(%9 5/!////5) 'ables(('able ; 1) L < J :)!Cell(3o 9 Col)!Select Selection!'e?t & Format(B9 5/!////5) 'ables(('able ; 1) L < J <)!Cell(3o 9 Col)!Select Selection!'e?t & Format(P9 5/!////5) End Sub &rocedure Save%aluesAir inserts the results calculated %ithout shield into
the
tables. Main procedure CommandButton>_Click is relatively long$ but simple. :t creates the problem and then in the loop the geometry and data are defined$ mesh built$ problem solved and results are stored in the tables. :f you have minimal experience in Visual Basic programming you may create this procedure by yourself. Sixth Step
(0
$esult tables.
Variable shield thickness.
)able *+ )ester "oltage V "s+ shield thickness+
Short-circuited shield )opper Steel 5.5+-5.5+,, 5.5(;, 5.5(-, 5.5(,( 5.5(-5 5.552' 5.55-J 5.550, 5.55-+ 5.55'; 5.55(,
6pen-ended shield )opper Steel 5.5+'' 5.5+'' 5.5+', 5.5+'5.5+', 5.5+'' 5.5+'' 5.5+'J 5.5+'J 5.5+'2 5.5+'5.5+''
Without shield
5.5+''
Short-circuited shield )opper Steel 5.55(0 5.55(0 5.55(, 5.55(5 5.5552 5.55(5 5.555J 5.555, 5.555' 5.555, 5.5555.555(
6pen-ended shield )opper Steel 5.55(; 5.55(; 5.55(; 5.55(; 5.55(0 5.55(; 5.55(J 5.55(J 5.55(J 5.55(0 5.55(0 5.55(0
Without shield
5.55(0
Short-circuited shield )opper Steel ;.'-0; ,;.J0;; ;.,5J+ '-.2'+;.(025 ,J.J,'2 0.22(; ',.++'5 0.;J5, -'.0+(+ 0.0J0+ ',.2;(+
6pen-ended shield )opper Steel ;.5(2; (J.-'J( 0.,J;0 (50.5J;0 0.,0-, (5(.;';; 0.,;', 0;.JJ50 0.-5+0 J+.0J,' 0.-+J( 0+.2,,-
Without shield
0.,JJ2
(;
Without shield
5.5+''
Without shield
5.55(0
Without shield
0.,JJ2
(2
Without shield
5.5+''
Without shield
5.55(0
Without shield
0.,JJ2
+5
&mage copying EetPicture method from class Field$indo copies a picture to the clipboard.
$in!EetPicture
&nsert position setting To paste the image from the clipboard into Word document you should set the cursor CselectionD in the needed position. :t is convenient to prepare the boo"mar" in advance and then set the cursor to this boo"mar".
Selection!Eo'o $1atI& dEo'oBookmark9 NameI&5Picture15
&mage pasting and resi#ing 8o% you may paste the picture and ad1ust its si7e.
+(
Second image should be inserted by the same %ay. Plotting We %ill not discuss here the code for plotting. >ou may bro%se it in VB pressing ltI#((. editor by
Tables + and , content the data for plots of the parameters vs. thic"ness. Before ma"ing plots you should fill up the tables Crun BSixth StepBD. /et #ield &ictures 9ra% /raphs
++
+,
$esult graphs.
Tester voltage vs. shield thickness
0.03
0.025
Tester voltage V
0.02 Short!circuited copper 0.015 Short!circuited steel "pen!ended copper "pen!ended steel 0.01
0.005
100
%0 #oule heat & Short!circuited copper $0 Short!circuited steel "pen!ended copper "pen!ended steel 40
20