# Demonstration # Creating a sequence of 100 BMP files to show the variation of potential # along an axis of an electrostatic solution # File names set to generate an AVI animation with CECIL_B # Stanley Humphries, Field Precision, Copyright 2010 import subprocess # --------------------- # Set control parameters # Range and step size along z axis ZMin = -0.065 ZMax = 0.065 NStep = 100 dZ = (ZMax-ZMin)/NStep # Graphics file resolution XRes = "640" YRes = "480" # File names # Saved surface plot view to set style, orientation and view limits. The # variable parameter (SurfacePlanePos) has been replaced with @ ViewTemplate = "template.fpv" # Temporary view file with different values of SurfacePlanePos ViewTemp = "temp.fpv" ViewTempPrefix = "temp" # Script file to call phiview, referencing the current view file Script = "pvscript.scr" ScriptPrefix = "pvscript" ProgName = "phiview" # --------------------- # Loop along the z axis for n in range(NStep+1): Z = ZMin + n*dZ # Create the temporary view file, replacing @ with the current position Z InView = open(ViewTemplate,'r') OutView = open(ViewTemp,'w') while 1: line = InView.readline() if not line: break line = line.replace("@",str(Z)) OutView.write(line) InView.close() OutView.close() # Create the BMP file prefix if n < 10: BMPFilePrefix = "bmpout" + "00" + str(n) elif n < 100: BMPFilePrefix = "bmpout" + "0" + str(n) else: BMPFilePrefix = "bmpout" + str(n) print BMPFilePrefix # Write the PhiView script OutScript = open(Script,'w') OutScript.write("INPUT TARGET.HOU\n") PlotCommand = "PLOT " + ViewTempPrefix + " " + BMPFilePrefix + " " + XRes + " " + YRes OutScript.write (PlotCommand + '\n') OutScript.write ('ENDFILE\n') OutScript.close() # Run phiview to generate the BMP file Command = ProgName + " " + ScriptPrefix subprocess.Popen(Command).wait() # ---------------------