Automated Creation and Export of CFD Results
Previously I showed how to automate a sequence of Caedium Computational Fluid Dynamics (CFD) simulations of an alpha sweep for an airliner. Next up I will show you how to automate the export of results from Caedium in a specific format. This example focuses on the files required for ixCube 4-10 (the successor to ixForten 4000) to perform a structural analysis using the pressure coefficient (Cp) from an airflow simulation over a tensile structure or membrane.
Background
ixCube 4-10 requires the geometry (in Alias/Wavefront .obj) and membrane Cp (in Comma Separated Values .csv) files to perform a structural analysis. As described in the section "Export Results to ixCube 4-10" in the tutorial "Flow Over a Double-Sided Membrane" Caedium can provide these files, but the sequence is not easy to remember if you are not performing the operation on a regular basis. This is a prime candidate for automation using Caedium's inbuilt Python record and playback capability.
How To
To create the template script for this automation example, run through the tutorial until you reach the section "Export Results to ixCube 4-10", then:
- Change the name of the membrane face_6 to membrane.
- Change the name of the membrane shadow face_6-shadow to membrane-shadow.
- Select the File Toolbar, toggle Record, and save the recording as Export-ixCube-4-10.py .
- Proceed with the tutorial to the end - remember you have renamed the membrane faces.
- Select the File Toolbar, and toggle Record to stop the script recording.
- Edit the script to make the exported file names relative to the current working directory.
The script is now complete and ready to export files. All you need to do next time you want to export to ixCube 4-10 is:
- Run your simulation.
- Name your membranes according to the naming convention in the script.
- Select the File Toolbar, click Play, and select your script (Export-ixCube-4-10.py).
Notes
- The Python script (minus the header and imports):
class Script: """Caedium Script """ def run(self): selection = caedium.select.View(simulation = 'sim', view = 'view', camera = 'camera') selection.select() tool = caedium.file.NewView() tool.addTo(selection) selection = caedium.select.View(simulation = 'sim', view = 'view_1', camera = 'camera') selection.select(['membrane']) property = caedium.frm.Property('Transparent', selection) property.appendParent('View') property.set(False) selection.selectAllEdges() property = caedium.frm.Property('Transparent', selection) property.appendParent('View') property.set(True) selection.selectAllAxes() property = caedium.frm.Property('Transparent', selection) property.appendParent('View') property.set(True) selection.select() tool = caedium.file.Export('membrane-cp.obj', 'obj') tool.addTo(selection) selection.select(['membrane', 'membrane-shadow']) tool = caedium.tool.result.ScalarField('PressureCoefficient') tool.addXYPlotTo(selection) selection = caedium.select.Plot('Cp Plot') selection.select() tool = caedium.file.Export('membrane-cp.csv', 'csv') tool.addTo(selection) if __name__ == '__main__': caedium.frm.Application.run(Script())
- Download the entire script at Export-ixCube-4-10.py.
- You can also use this method of imposing a naming convention for your script to set up entire simulations after importing a complete geometry model.
- Review file names in scripts, by default the full path is recorded. Often you'll want to just reference the filename (rather than the full path), which will then be written to the current working directory.
Recent blog posts
- CFD Simulates Distant Past
- Background on the Caedium v6.0 Release
- Long-Necked Dinosaurs Succumb To CFD
- CFD Provides Insight Into Mystery Fossils
- Wind Turbine Design According to Insects
- Runners Discover Drafting
- Wind Tunnel and CFD Reveal Best Cycling Tuck
- Active Aerodynamics on the Lamborghini Huracán Performante
- Fluidic Logic
- Stonehenge Vortex Revealed as April Fools' Day Distortion Field