Skip to content

Add Gaurav's simulations as an engine#91

Open
christophlohrmann wants to merge 8 commits intomasterfrom
gaurav_sim
Open

Add Gaurav's simulations as an engine#91
christophlohrmann wants to merge 8 commits intomasterfrom
gaurav_sim

Conversation

@christophlohrmann
Copy link
Copy Markdown
Collaborator

@christophlohrmann christophlohrmann commented May 13, 2024

Done:

  • Basic implementation of eq of motion and integration
  • Trajectory writing
  • Test if it runs

To Do:

  • Units
  • Actual testing
  • Tying in the new set of actions into the framework of our existing actions
  • Reproducing some simulations from the paper

Future:

  • Implement RL models that use the new actions

christophlohrmann and others added 5 commits May 13, 2024 15:07
Copy link
Copy Markdown
Collaborator

@SamTov SamTov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me; I don't have a good understanding of the simulation side of things. Depending on how broad it will be, we could update the documentation side, but I would leave this for Gaurav.

I had a few comments regarding old code and the use of numba. I would prefer to just use Jax as it will also then compile nicely with the other parts of SwarmRL which also compile with Jax. I think it will also reduce the number of large dependencies. But if there is a real reason for it then I am open.

The other larger point is the use of a new Model. I think it would also be possible to reuse our ForceFunction parent class or, as I write in the comment, make a slightly more general parent class and start branching off with Espresso and MPI children.

)


@numba.jit
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to with numba here and not Jax? If one requirement already includes GPU support and JIT compile I would lean towards sticking with that unless there is a reason not to.

phi_i = state[i, 2] - r_ij_angle
phi_ij = phi_i

# f_mag_on_prefactor = (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the old code here?

Comment on lines +11 to +12

from swarmrl.engine import Engine
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the full import path.

Comment thread swarmrl/engine/gaurav_sim.py Outdated
)
for _ in range(n_slices):
# Check for a model termination condition.
if model.kill_switch:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a kill_switch check.

offsets: np.array


class Model:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have these inherit from our ForceFunction? It sees like most of the code can be reused we should just rename colloids to particles or something along those lines. Perhaps we make a more general parent for the force functions so that we can have an ESPResSo and newer ones which then get their own custom type hints and we can do some checks when users try to use espresso actions in an MPI simulation. What do you think?

round(self.params.time_slice / self.params.snapshot_interval)
)
for _ in range(n_slices):
# Check for a model termination condition.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a kill switch here but commented it out as without the main parent classes for the force model it will break the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants