|
From: | Jean-Noël Grad |
Subject: | Re: Gradient magnetic field |
Date: | Fri, 8 Mar 2024 15:48:24 +0100 |
User-agent: | Mozilla Thunderbird |
Hi Kseniia,This feature doesn't exist yet, but the necessary building blocks are available. There is certainly more than one way to implement it, but here is how I would go about it. Starting from the FlowField [1], whose equation is force = -gamma * (u(p.pos) - p.v), one can substitute unity for gamma, p.dip for p.v, and use an appropriate vector product expression instead of the subtraction. The position-dependent quantity u is a vector field, which in ESPResSo is stored in a class that provides a definition for the corresponding Jacobian matrix. Therefore all ingredients to compute forces and torques should already be here.
The new C++ kernel can be adapted from the Viscous class [2], and needs to return a ParticleForce object, which stores two Vector3d objects for the force and torque (right now the Viscous kernel only returns a Vector3d for the force). Then one has to implement a script interface class adapted from FlowField [3], with a different name and taking as template parameter the new kernel class instead of the Viscous class, and register it in the initializer list [4]. Finally one has to create the corresponding Python class by adapting the FlowField one [5].
If you are familiar with C++ and template programming, and have time to develop code, this should be within your reach. The feature can be developed in two stages, starting with the C++ kernel and a unit test based on the Viscous test [6] to run it with a mock Particle class [7]. Then the Python class and script interface can be designed. You could join our coding days remotely via Zoom if you need assistance with this coding project.
Best, JN Links:[1] https://espressomd.github.io/doc/espressomd.html#espressomd.constraints.FlowField [2] https://github.com/espressomd/espresso/blob/7ad0534/src/core/field_coupling/couplings/Viscous.hpp#L36-L40 [3] https://github.com/espressomd/espresso/blob/7ad0534/src/script_interface/constraints/initialize.cpp#L46 [4] https://github.com/espressomd/espresso/blob/7ad0534/src/script_interface/constraints/initialize.cpp#L57-L58 [5] https://github.com/espressomd/espresso/blob/7ad0534/src/python/espressomd/constraints.py#L516-L542 [6] https://github.com/espressomd/espresso/blob/7ad0534/src/core/unit_tests/field_coupling_couplings_test.cpp#L99-L117 [7] https://github.com/espressomd/espresso/blob/7ad0534/src/core/unit_tests/field_coupling_couplings_test.cpp#L82-L88
On 3/8/24 08:14, Ксения Астахова wrote:
Hello everyone!I want to create a gradient magnetic field, but I see that this functionality isn't supported yet. I was wondering if anyone had implemented it or knows how to deal with it.Best wishes, Kseniia
[Prev in Thread] | Current Thread | [Next in Thread] |