Tips for macro writing after maxcompute 2D parameterization Processing

Source: Internet
Author: User
Maxwell 2D Parameters Post-processing during analysis Result Sometimes manual processing is very inconvenient. In this case, we need to use a macro method to solve the problem. Here we only propose a solution. If you have a better solution, please talk about it.
& M-S2 R-l s! D7 ^ 1. How to obtain the calculated parameter value
9 L1 [& O: S4 A5 A7 H + A6 | In 2D post-processing, you cannot directly call the variables in the pre-processing (currently I have not found a method to directly access the variables, please let me know), so you only have to find a way to get the current variable value, through File You can find that the initial. cn2 file contains information about the current variable value in each step of variable analysis. For example, the following content is from initial. cn2:
5 K $ R2 l8 p -? + S "s, M + d $ _) _ 9 h B _symtab & I #}; @ "V # V
Nthickness = 20
& S2 H + V % U3] E_symtab
8 U1 B, E! A # Z3 v $ s Here there is a variable named nthickness, so the following macro is to get the nthickness value from initial. cn2:
I @ # M # T! [1 E4 Q8 z5] Assign sparafile "Initial. cn2"
4 J "J6 l r$ r'e & M # I/B6 F ,[! N6 B0 P8 V3 H/z "V7 C & I
# Determine whether the file initial. cn2 exists
9 p; J6 N2 O0? +] 1 y Assign nreturn fileexists (sparafile)
'F * _ % u % ^-Z % i8 G8 P If EQ nreturn 1
'{/L # f) I) G1 D .{ # Open this file if it exists
8 S7 '"H6 j0' 3 C! C Fileopen sparafile
, S # Y: J "O! M "F # U2 t # Formatting and reading from a file Data To store the data list in strlist.
) T8 y "d (^ 6 q; H Assign strlist fileread sparafile '$ "nthickness =" $ l ':?, W C4 {; R
# Close the file "X; \ & H + U/E, C + S6? $ O Z4 e! O0 d
Fileclose sparafile $ v. A5 S4 F8 O5 S _ 6 m
# Assign the first data in the data list to nvalue
9 B3 r'v. U "}. C & G. V5 A D0 P Assign nvalue component 1 strlist
3 C;} 6 C'] 1 F! D. P7 L/P + S End
1 @ 4 K4 M9 [(I "B9] In this way, the nvalue is saved as 20. With this value, you can divide the time zone of the post-processing result into different curves or save it as z7 P;]-~ 7 d % G + u
1 Q! ] "A2 O) '6 x
2. How to export the magnetic induction intensity of a straight line 7 B; H4 p! H; l8 v) f
I have mentioned this in a previous post. Command For more information about macro usage, see the macro manual. Solution The result outputs a line of magnetic induction intensity curve, and all the results are stored in the result_linein.dat file, while the curve name is defined as the value of linein + nvalue, through this, we can easily distinguish the meaning of each curve. We need to observe the graph and use the plot directly. Program Open it. "? * @ # A # X % u &\
Editpline "linein" # F $} $ C ;? 2 F & r w. K "') x
Addvert [12, 0, 0] # J (B "] 2g, i8
Addvert [12,249.75, 0]
) K _ q (J-B6 R8 K9 C6 G9 s Endpline 0
7]'t) T4 N # B $ h; O4 A; u * z, M:} 0 N: E Enter "B"
;~; N + Q! E' [6 V $ L x Mag9 C2 v. s 'U; [1 ^ (o) f
Smooth0 E (B; M4 J2 [(D2 B
Enterline "linein" H & L + E3 ~ *? 9 I $ @
Assign sfilename "result_linein.dat "! U * W7 \. H8] 5 z) f (G6 J
Assign slinename strconcat "linein" nvalue/V) R8 l0 [8 \ 'd % _ & L * D! Z
Assign nreturn fileexists (sfilename)
'| 4 O, s' K0 Q * G3 o-F If EQ nreturn 1, S6 I; O4 {+ P4 _ 0 _ (|
Load2dplot sfilename (c) q; Y. w'q) f
Lineplot2d slinename 10 2 3 1 0 1 0; c s * Z1 T. S
Else0 ~ D u! O-{'l
Lineplot2d slinename 10 2 3 1 0 1 1
0 R7 U4 R0 P8 F; G End
& | 5 @ # B "G + Z) O & P: m Save2dplot sfilename; G: V 'ks' E
Closewindow :~! F # S * H5 B9 s
Clear
3 C8 H "K % Z! N) Z8 P4 g f # W Deleteline "linein"
& O! J9 X "G8 Y3 C-^ 6 N 3. How to output the value of a vertex 7 [1 B; q (C4}: Q; [: N6 C
The method is similar to that of the output line, but the file output must adopt the direct read/write method: 4 B ++ ?; Z, y6 X! M) Y. _; W, _ 8 L
Definepoint "ptmid" [15, 14, 0]
% Q) r'v9 o $ T6 K Filewrite sfilename "A" "$ \ t" {nvalue}
: F'' + V *? & P! '* K Enter "B" 8 q'j & L "F $ J
Mag9 '1 Z (S, H3 y
Enterpoint "ptmid": N. A6 F, ^ 7 _ 'w1 N2 z0 n-I; f
Value0? 5 Q1 S $ R0 Q/I; F # ^ ;? 3 I + [
Evaluate
: U "E4 C 'g1 D. U $ R (C Assign ntemp gettopentryvalue! E/G: Q "[3 O $ N *{
Filewrite sfilename "A" "$ \ t" {ntemp} 5 _ 3 Q7 f \ 5 G6 y
+ T & l8 P (') \ U

7 V6 t "f, U0 y9 D3] 5 JClear9 f c &~ : B L! F G3 x9}
Deletepoint "ptmid" # E3 C/l5 B: J "? 0]
/B) f (l7 H, Q $ @ & [: R % J1 T5 v
Each row of the output file represents the result of one step. The first data is the current parameter value, and the second is the result of the solution. This file can be viewed on the WordPad. 3 P-r! F't4 g
. Users ~ 5 H! O! D' I $ l-S
The macro is not described in detail in this article. For detailed usage, see Introduction to the Ansoft macro language.pdf in the official manual.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.