outfile = "iron_entry_results.txt" -- read projectile's position at its centerpoint handle = openfile("tempfile","r") position = read(handle,"*n") closefile(handle) -- define contour clockwise around the 10mm-long projectile -- it needs to be ~2 mesh units outside the iron length = 30 -- length of projectile (mm) r = 2.25 -- radius of projectile (mm) mesh = 0.4 -- mesh size inside iron projectile top = position + length/2 + mesh*2 bot = position - length/2 - mesh*2 add_contour(0, top) -- upper left add_contour(r+mesh*2,top) -- upper right add_contour(r+mesh*2,bot) -- lower right add_contour(0, bot) -- lower left add_contour(0, top) -- and back to start -- STRESS TENSOR: compute mechanical force upon contour around projectile radial_force_real, radial_force_imag, axial_force_real, axial_force_imag = line_integral(3) -- LORENTZ FORCE: mechanical force on coil -- Note: We can't use the (simpler) Lorentz force calculation because the -- coil's force is unbalanced due to a single iron end cap. -- groupselectblock(2) -- lorentz_force = blockintegral(12) * (-1) handle=openfile(outfile,"a") write(handle, position, "\t", axial_force_real, "\n") closefile(handle) exitpost()