Command line simulations

From OpenPSTD
Jump to: navigation, search

Simulations can be ran directly from the Blender interface providing users with an interactive overview of the progress of their simulation. However, for simulations that take a long time to complete, users might want to defer the calculation to a more powerful system or disconnect it from the graphical user interface.

Note that the v1.0 release of openPSTD will not benefit tremendously from a multi-threaded computing environment as the Python based computation model is not parallelized.
  • Tick the 'Advanced' checkbox in the openPSTD interface
  • and untick 'Run simulation'
  • Observe how the 'Simulate with openPSTD' button now turns into 'Export scene definition'
  • Clicking this buttons prompts the user with a save file dialog in which users can provide a name and path for their scene definition, for example: 'scene.json'

Example scene definition file

{
    "domains": [
        {
            "topleft": [
                0.0, 
                0.0
            ], 
            "size": [
                10.0, 
                10.0
            ], 
            "id": "20140903_1009_Plane_face-0", 
            "edges": {
                "l": {
                    "a": 0.0, 
                    "lr": false
                }, 
                "b": {
                    "a": 0.0, 
                    "lr": false
                }, 
                "t": {
                    "a": 0.0, 
                    "lr": false
                }, 
                "r": {
                    "a": 0.0, 
                    "lr": false
                }
            }
        }
    ], 
    "calctime": 1.0, 
    "c1": 340.0, 
    "ampmax": 20000.0, 
    "receivers": [], 
    "rho": 1.2000000476837158, 
    "plotdir": "./openPSTD_plots_20140903_1009", 
    "patcherror": 70.0, 
    "speakers": [
        [
            5.0, 
            5.0, 
            0.0
        ]
    ], 
    "tfactRK": 0.5, 
    "grid_spacing": 0.20000000298023224, 
    "PMLcells": 50
}
  • Next step is to make sure there is a Python environment with Numpy installed
    • This can be a Blender installation starting with version 2.70
    • This can be a scientific Python distribution such as Anaconda http://continuum.io/downloads
    • This can be a regular Python installation, either manually or from your operating system's package manager
  • When using Blender on Windows with the openPSTD addon installed, the simulation can be invoked by issuing on the Command Prompt:
"C:\Program Files\Blender Foundation\Blender\blender.exe" -b -P "%APPDATA%\Blender Foundation\Blender\2.71\scripts\addons\openpstd\kernel\pstd.py" scene.json
NB1 Other operating systems use different paths, but the procedure will be similar
NB2 Depending on installation procedure and Blender version, the installation paths might be different even on Windows
NB3 The -b -P command line flags are specific for Blender. Omit them when using a regular Python interpreter
NB4 Take special care of the "plotdir" attribute in the scene description file. The openPSTD simulation kernel will try to create this directory if it does not exist
  • This simulation will run until "calctime" (in seconds) has been reached. Note that this is the time amount for which simulation frames will be generated not the time spent on the actual simulation.
  • At the end of the simulation data can be read from the "plotdir" directory. It will contain binary data for the pressure level grid cell as well as the receiver positions. If matplotlib is installed this will include a .png graphical image as well.