# Run multiple simulations in parallel using XML-RPC

**URL:** <https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651>\
**Category:** PLECS\
**Tags:** simulations, parallel, xml-rpc\
**Created:** [April 23, 2019, 8:15am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651 "2019-04-23T08:15:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![msta](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@msta](https://forum.plexim.com/u/msta)\
**Post date:** [April 23, 2019, 8:15am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/1 "2019-04-23T08:15:15Z")

</div>

Hello,

after some trouble, I can now use the XML-RPC interface to open and run PLECS-simulations from an external tool. But it seems, I can only run one simulation at once: set one parameter, run, wait for the result, modify parameter again, run again, wait for result, …Is is possible, to start multiple simulations on a multicore-system in parallel? I’d need to start PLECS with command line parameters like -multipleinstance -rpcport 1081 -nogui

Is this possible?

---

<div class="post-metadata">

**Author:** ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)\
**Post date:** [April 23, 2019, 12:27pm UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/2 "2019-04-23T12:27:06Z")

</div>

Hello, unfortunately this is not possible currently.

EDITED: [Parallel simulation is now available natively in PLECS Standalone.](https://plexim.com/support/examples?field_demo_model_product_value=1&body_value=5&body_value_1=All) Look at the “PLECS: Buck Converter with Parameter Sweep” demo model.Thank you,Kris

---

<div class="post-metadata">

**Author:** ![msta](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@msta](https://forum.plexim.com/u/msta)\
**Post date:** [April 24, 2019, 4:30am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/3 "2019-04-24T04:30:58Z")

</div>

Well, I think, one could work around this by using a different user for each process. But this would cost too much extra-effort for my project.

So I would like to see such a feature soon 🙂

One more idea: The float-to-string/string-to-float conversions and the XML parsing of the XML-RPC response costs a significant percentage of CPU-time. For transfering large result data arrays, a memory mapped buffer (shm\_open+mmap for Linux, OpenFileMapping+MapViewOfFile for Windows) would be nice. The XML-RPC could then deliver the name and size of this file.

---

<div class="post-metadata">

**Author:** ![tinivella](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@tinivella](https://forum.plexim.com/u/tinivella)\
**Post date:** [June 3, 2019, 3:41am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/4 "2019-06-03T03:41:58Z")

</div>

what happen if you run multiple file with different filename can be run in parallel?

---

<div class="post-metadata">

**Author:** ![tinivella](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@tinivella](https://forum.plexim.com/u/tinivella)\
**Post date:** [October 31, 2019, 7:25am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/5 "2019-10-31T07:25:09Z")

</div>

hi I wrote a workarund in python to do that you can find on my github [https://github.com/tinix84/pyplecs](https://github.com/tinix84/pyplecs)

---

<div class="post-metadata">

**Author:** ![msta](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@msta](https://forum.plexim.com/u/msta)\
**Post date:** [June 3, 2022, 10:06am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/6 "2022-06-03T10:06:27Z")

</div>

\*please delete this comment, I moved it to the the other sub-topic: [https://forum.plexim.com/874/run-multiple-simulations-in-parallel-using-xml-rpc?show=1786#a1786](https://forum.plexim.com/874/run-multiple-simulations-in-parallel-using-xml-rpc?show=1786#a1786)  
thx

---

<div class="post-metadata">

**Author:** ![msta](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@msta](https://forum.plexim.com/u/msta)\
**Post date:** [June 3, 2022, 10:12am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/7 "2022-06-03T10:12:59Z")

</div>

I’ve hat some other projects to work on during Corona… Now I’m back 😉

Well, I read through the Buck Converter with Parameter Sweep. The Command to run the simulation looks like

```auto
plecs('simulate', simStructs, @(index, data) callback(index, data))

```

where simStructs is not just one set of parameters to be modified but an array of such structs. Then there is a third parameter, I guess a pointer to a callback function. But how is this call done in XML-RPC?

---

<div class="post-metadata">

**Author:** ![msta](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@msta](https://forum.plexim.com/u/msta)\
**Post date:** [June 5, 2022, 8:51am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/8 "2022-06-05T08:51:18Z")

</div>

I tried to clone the .plecs file with updated name-attribute. But when starting this in parallel, I get the error

```auto
Error: thread 1 Simulation error: method execution error:
       The server is busy executing the blocking command "simulate('test_0')".

```

test\_0 is the file, generated by thread 0, which is running without problems.@[tinivella](https://forum.plexim.com/user/tinivella) What’s the trick in your python-script?

---

<div class="post-metadata">

**Author:** ![tinivella](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@tinivella](https://forum.plexim.com/u/tinivella)\
**Post date:** [June 6, 2022, 3:52am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/9 "2022-06-06T03:52:28Z")

</div>

I dont know if PLECS changed the server structure,

simply my Python script handle the program pointer to interact the Plecs GUI with python instead of using the XML server.

For this I use pyautogui and os.path to duplicate the simulation files.

if you need we can do a teams session

---

<div class="post-metadata">

**Author:** ![msta](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@msta](https://forum.plexim.com/u/msta)\
**Post date:** [June 6, 2022, 12:59pm UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/10 "2022-06-06T12:59:57Z")

</div>

Interesting. Yes, you can find me on [https://mitjastachowiak.de/?/sonstiges/kontakt.html](https://mitjastachowiak.de/?/sonstiges/kontakt.html)

Hope some of my contact ways work for you 😉

---

<div class="post-metadata">

**Author:** ![zhihao\_chen](https://avatars.discourse-cdn.com/v4/letter/z/53a042/32.png) [@zhihao\_chen](https://forum.plexim.com/u/zhihao_chen)\
**Post date:** [March 18, 2025, 9:55am UTC](https://forum.plexim.com/t/run-multiple-simulations-in-parallel-using-xml-rpc/651/12 "2025-03-18T09:55:35Z")

</div>

Thank you for providing the code. I tried running it, but it seems that I cannot get their output when running multiple simulations in parallel using GUI. Using RPC communication can easily obtain output, but how can GUI obtain output data
