espressomd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vectorial manipulation


From: Jean-Noël Grad
Subject: Re: vectorial manipulation
Date: Sat, 29 Jan 2022 14:10:42 +0100
User-agent: Roundcube Webmail/1.3.17

Dear Shammi Babar,

You can use the following solution:

```python
p = system.part[0]
v = np.copy(p.v)
v[1] += 0.2
p.v = v
```

You can wrap this solution in a function to make the pypresso script more readable. Here is a minimal working example:

```python
import espressomd
import numpy as np

def update_particle_velocity(system, pid, v):
    p = system.part[pid]
    p.v = np.copy(p.v) + v

system = espressomd.System(box_l=[10, 10, 10])
system.part.add(id=1, pos=[0, 0, 0], v=[0, 0, 0])
update_particle_velocity(system, 1, [0.1, 0.2, 0.3])
print(system.part[1].v)
```

Best,
JN

On 2022-01-29 12:50, Shammi Babar wrote:
dear espresso users,

I have a question about vectorial particle properties in espresso. in
fact I need to replace velocity of some specified particles with new
values during simulation, but as explained in user guide:
https://espressomd.github.io/doc4.1.4/particles.html (section 4.3.1)
it is not allowed and will result in an error.
could you please help me solve this issue?

thanks



reply via email to

[Prev in Thread] Current Thread [Next in Thread]