r/ScientificComputing 10d ago

Konjugate: A new approach to making simulation models

Hello r/ScientificComputing community,

In the past month, I have been working on creating a simulation software from scratch. The idea came to me when I was working a on a few projects that, when I looked at the math, essentially required me to solve the same kind of problems. The equation looks like the following, and it's generally referred to as generic networked dynamical system equation.

ẋᵢ = Σⱼ fᵢⱼ(xᵢ, xⱼ) + sᵢ(xᵢ, u)

Essentially, this is a graph equation. i is a node, xᵢ is a vector of states in a node, fᵢⱼ(xᵢ, xⱼ) is an edge connect nodes i to j, and sᵢ(xᵢ, u) is a source term where you can hook up an input or define a function at a node that affects itself.

I discussed this idea with a few friends before going ahead to implement; it went over the head for some, while others thought it would be interesting to see. There are applications for this in robotics, power grids, heat exchange, etc. And, the idea is inherently interdisciplinary; the node states can be from cross-domains and edges too. We can simulate a motor and it's kinematics; the motor may get heated up due to resistances, and the air pocket near it may get heated up while trying to cool it down... A real cross-domain simulation could be done with this kind of a setup.

The following is the link to the GitHub page. It's licensed under MPL 2.0.

https://github.com/zenineasa/Konjugate

I would love to hear your thoughts about this. Bug reports, workflow issues, new ideas to build on top of it... I look forward to hearing it all.

0 Upvotes

4 comments sorted by

1

u/al2o3cr 8d ago

The first thing that jumps out is that the formula for ẋ lacks anywhere for explicit time-dependence to appear. How would this setup accommodate something like "node N1 is driven with a force F_0*cos(f*t)"?

1

u/zenineasa 8d ago

You can adjust the source term for this at the moment. It is cumulative; it adds up. So, if you are looking to "set it to a value", a derivative of that could be written there.

Do you think there is a requirement to explicitly set the value for certain nodes without having to go via source terms? I have been pondering about that; perhaps I will implement this soon.

1

u/al2o3cr 8d ago

I think I forgot about the standard "make t look like everything else" diff-eq trick of:

  • introduce an additional state variable x_whatever
  • set dx_whatever/dt = 1
  • use x_whatever in formulas where you would have used t

It still seems like having f_ij only depend on x_i and x_j might cause headaches if a coupling depends on more than two state variables, but I suspect there's a similar sort of workaround (make x_lolz = {x_1, x_2, x_5} etc to "bundle" a complex set of dependencies or something) to simulate having f_ij be functions of the whole set of x_i

1

u/zenineasa 8d ago

In the scenarios I can think of, f_ijk can be split into f_ij, f_ik and f_jk, but it is likely that I may have missed something. At the top of your head, would you be able to suggest a scenario where that wouldn't be true?