outfile = "coil_diameter_results.txt" handle=openfile(outfile,"a") write(handle, "\nComparing various coil diameters \n") write(handle, "Projectile is 15mm long and 2mm radius\n") write(handle, "Coil is 20mm long with constant cross-section\n") write(handle, "Coil inside radius varies:\n") write(handle, " 2.1, 3.1, 4.1, ..., 30.1mm\n") write(handle, "To import in Excel:\n") write(handle, " Data - Get External Data - Import text file\n") write(handle, " then choose the file written by this program\n") write(handle, " and click Finish.\n") write(handle, "This data file is tab delimited\n") write(handle, " (Excel's default import format)\n") closefile(handle) -- Save the model in temporary file just to be safe save_femm_file("temp.fem") -- Set edit mode for selecting and moving projectile (and coil) -- using simple commands seteditmode("group") -- This is how much to increase the coil size between each trial increment = 1.0 for i=0,27 do -- New inner radius is starting size plus how much it has increased radius = 2.1 + i*increment -- Announce the coil dimensions in the results file handle=openfile(outfile,"a") write(handle, "\n") write(handle, "Coil inside radius = ", radius, " mm\n") write(handle, "Coil outside radius = ", radius+3.0, " mm\n") write(handle, "\n") closefile(handle) -- Move the projectile through 40 positions along the axis -- and find the force at each spot for n=1,40 do showmesh() analyse() -- Pass current position into post-processor handle=openfile("tempfile","w") pos = n-41 write(handle, pos) closefile(handle) runpost("coil_diameter_post.lua") -- Nudge projectile another millimeter upward into coil selectgroup(1) move_translate(0,1) end -- Move projectile back down to starting position outside coil selectgroup(1) move_translate(0,-40) -- Increase the coil's inner and outer radius selectgroup(2) move_translate(increment,0) end messagebox("All done!")