Is there a method to start the calculation of DualSPHysics automatically?


Dose anyone know how to start the calculation of DualSPHysics automatically?

I want to carried out numerical simulation about balls sliding into water. And i have designed many stacking form (about 300 types) of balls. Mannuly start the calculation one by one is quite annoying!

So, Is there a method to start the calculation of DualSPHysics automatically?

Best regards!


  • Hi,

    It is very possible to do what you want. I've done it with python for my application (not sharable though).

    With any code language, you can create the files needed to setup simulations and execute DSPH code automatically.

    Good luck

  • edited June 2023


    Not a topgun in programming, but I use Python in order to automatize the modification of XML entries cards and the launch of calculations in an MS-DOS environnement.

    In Python, you need the following libraries :

    # XML i/o
    import xml.etree.ElementTree as ET
    # External execution
    import subprocess

    I use a template XML, in which I update some parameters. I then execute a batch file to launch calculations. This is how I load the XML template, using ElemenTree into python environnement.

    # load template
    global tree
    global root
    loading_case = "TF10_mmo.xml"
    tree = ET.parse(loading_case)
    root = tree.getroot()

    Discretisation parameter dp is set using :

    # set precision
    dp = 0.15
    element = root.find("./casedef/geometry/definition")

    Here is a loop that executes DSP calculations after updating the position of the center of gravity of a floating object, assuming Gyp and Gzp downbelow are arrays of lenght n.

    At each iteration, the xyz coordinates of the center of gravity are updated, the XML template is overwritten, and copied into the execution folder, under the name CaseCurrentHull_def.xml. The batch file is executed, commanding the pre-processing, the calculation launch and the post-processing. Post-processed files are copied to a folder for further analysis.

    CenterOfGravity = root.find("./casedef/floatings/")
    for i in range(0,n):
        tree.write("tf10-00.xml")"copy d:\jupyter\tf10-00.xml C:\DualSPHysics_v5.0\examples\inletoutlet\09b_stabilite\CaseCurrentHull_Def.xml /Y", shell=True)"stabilite.bat", shell=True)"copy C:\DualSPHysics_v5.0\examples\inletoutlet\09b_stabilite\TP70_force.csv d:\TP70_force_" + str(i) +".csv", shell=True)"copy C:\DualSPHysics_v5.0\examples\inletoutlet\09b_stabilite\TP70_forcey.csv d:\TP70_forcey_" + str(i) +".csv", shell=True)"copy C:\DualSPHysics_v5.0\examples\inletoutlet\09b_stabilite\TP70_forcez.csv d:\TP70_forcez_" + str(i) +".csv", shell=True)"copy C:\DualSPHysics_v5.0\examples\inletoutlet\09b_stabilite\TP70_mvt_mk31.csv d:\TP70_mvt_mk31_" + str(i) +".csv", shell=True)"copy C:\DualSPHysics_v5.0\examples\inletoutlet\09b_stabilite\CaseCurrentHull_out\boundary\Hull_0003.vtk d:\Hull_" + str(i) +".vtk", shell=True)"copy C:\DualSPHysics_v5.0\examples\inletoutlet\09b_stabilite\CaseCurrentHull_out\surface\Surface_0003.vtk d:\Surface_" + str(i) +".vtk", shell=True)

    Hope that it will be somehow usefull for someone. Cheers,

Sign In or Register to comment.