#!/usr/bin/perl -w # Create parts for a MagWinder script to represent a cosine coil # Field Precision 01/09 # ========================================================== # Set control parameters # Number of windings $NSet = 24; # Angles of windings in the x-y plane @Angles = (-70.8201,-59.5904,-51.2857,-44.2739,-38.0165,-32.2542,-26.8372,-21.6683,-16.6787,-11.8161,-7.0385,-2.3095,2.3095,7.0385,11.8161,16.6787,21.6683,26.8372,32.2542,38.0165,44.2739,51.2857,59.5904,70.8201); # Half length of the winding in z $zpos = 2.5; # Radius of winding $rcoil = 2.7; # Angular conversion $degtorad = 0.017453; # ========================================================== # Open a file to write the part sections $FileName = ">" . "CWINDING_PARTS.DAT"; open (OutData, $FileName); # ========================================================== # Loop over windings for ($N=1; $N < ($NSet+1); $N++) { $xpos = $rcoil*cos($degtorad*$Angles[$N-1]); $ypos = $rcoil*sin($degtorad*$Angles[$N-1]); printf OutData ("* Winding %2i\n",$N); # Line at negative x printf OutData (" Part\n"); printf OutData (" Type: Line\n"); printf OutData (" Fab: %8.4f %8.4f %8.4f %8.4f %8.4f %8.4f\n",-$xpos,$ypos,-$zpos,-$xpos,$ypos,$zpos); printf OutData (" End\n"); # Connecting arc at positive z $angdn = 180.0 - $Angles[$N-1]; $angup = $Angles[$N-1]; if ($angup < 0.0) {$angup = 360 + $angup}; printf OutData (" Part\n"); printf OutData (" Type: Arc\n"); printf OutData (" Fab %8.4f %8.4f %8.4f\n",$rcoil,$angdn,$angup); printf OutData (" Shift 0.0000 0.0000 %8.4f\n",$zpos); printf OutData (" End\n"); # Line at positive x printf OutData (" Part\n"); printf OutData (" Type: Line\n"); printf OutData (" Fab: %8.4f %8.4f %8.4f %8.4f %8.4f %8.4f\n",$xpos,$ypos,$zpos,$xpos,$ypos,-$zpos); printf OutData (" End\n"); # Connecting arc at negative z printf OutData (" Part\n"); printf OutData (" Type: Arc\n"); printf OutData (" Fab %8.4f %8.4f %8.4f\n",$rcoil,$angup,$angdn); printf OutData (" Shift 0.0000 0.0000 %8.4f\n",-$zpos); printf OutData (" End\n"); }; # ========================================================== # Wrap up close (OutData); # ==========================================================