407 views
Skip to first unread message

Elsaid Younes

unread,
Feb 15, 2021, 4:50:42 AM2/15/21
to hoomd...@googlegroups.com

Dear all,
I did the below script in order to start building up my model, but it did not rend out the desired gsd file. I also tried to creat_lattice, but it does not work out.



import gsd.hoomd
import numpy as np
import hoomd
import hoomd.hpmc

s = gsd.hoomd.Snapshot()
s.particles.N =2940
s.particles.diameter = [150.0]
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [0]
s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)


mc = hoomd.hpmc.integrate.sphere(seed=4552367,d=0.9,a=0)
mc.shape_param.set ('A', diameter = 150, orientable = False)

s = gsd.hoomd.open(name='file_b.gsd', mode='wb')

import gsd.hoomd
import numpy as np
import hoomd
import hoomd.hpmc

s = gsd.hoomd.Snapshot()
s.particles.N =2940
s.particles.diameter = [150.0]
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [0]
s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)


mc = hoomd.hpmc.integrate.sphere(seed=4552367,d=0.9,a=0)
mc.shape_param.set ('A', diameter = 150, orientable = False)

s = gsd.hoomd.open(name='file_b.gsd', mode='wb')
import gsd.hoomd
import numpy as np
import hoomd
import hoomd.hpmc

s = gsd.hoomd.Snapshot()
s.particles.N =2940
s.particles.diameter = [150.0]
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [0]
s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)


mc = hoomd.hpmc.integrate.sphere(seed=4552367,d=0.9,a=0)
mc.shape_param.set ('A', diameter = 150, orientable = False)

s = gsd.hoomd.open(name='file_b.gsd', mode='wb')
import gsd.hoomd
import numpy as np
import hoomd
import hoomd.hpmc

s = gsd.hoomd.Snapshot()
s.particles.N =2940
s.particles.diameter = [150.0]
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [0]
s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)


mc = hoomd.hpmc.integrate.sphere(seed=4552367,d=0.9,a=0)
mc.shape_param.set ('A', diameter = 150, orientable = False)

s = gsd.hoomd.open(name='file_b.gsd', mode='wb')


image.png

Best,
Elsaid

Eric Irrgang

unread,
Feb 15, 2021, 7:51:37 AM2/15/21
to hoomd...@googlegroups.com
Can you comment on what result you expected and how the result you encountered is different?

If this is all in one script, and this is the entire contents, then I see several issues, which I will annotate below.

> s = gsd.hoomd.Snapshot()
> s.particles.N =2940
> s.particles.diameter = [150.0]
> s.configuration.box = [906.0,906.0,906.0,0,0,0]
> s.particles.typeid = [0]
> s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)
>
>

You don't seem to do anything with the snapshot `s`, such as initializing a hoomd system from it.

> mc = hoomd.hpmc.integrate.sphere(seed=4552367,d=0.9,a=0)
> mc.shape_param.set ('A', diameter = 150, orientable = False)
>

The following line replaces the snapshot `s` with a file handle without having done anything with the previous `s`.

> s = gsd.hoomd.open(name='file_b.gsd', mode='wb')

Also, you open the file without ever explicitly closing it. Reassigning `s` should effectively accomplish closing the file, but it is better to close it explicitly. The best way to manage opening and closing a file is in a `with` block. See https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files for the pattern commonly used in Python.

You have already imported these. No need to import again.
>
> import gsd.hoomd
> import numpy as np
> import hoomd
> import hoomd.hpmc
>

The following line replaces `s`, closing the file without having written anything to it.

> s = gsd.hoomd.Snapshot()
> s.particles.N =2940
> s.particles.diameter = [150.0]
> s.configuration.box = [906.0,906.0,906.0,0,0,0]
> s.particles.typeid = [0]
> s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)
>

Again, you haven't done anything with `s`, such as writing to a file or initializing a simulation from it.

I won't comment further, because this pattern basically repeats.

The GSD file you visualized has no content because you never wrote anything to the file.


Elsaid Younes

unread,
Feb 15, 2021, 9:06:20 AM2/15/21
to hoomd...@googlegroups.com
Hi,

closing the file means s.close()? still empty file.

I tried to create_lattice, but I failed in writing the particles into it as I want to write two spheres [A,diameter1,charge1,N1] and [B,diameter2,charge2,N2], and the positions of the two types of sphere conflict with each other.
Note: "I got an error that hoomd has no attribute 'hpmc'" so I tried to import it import hoomd.hpmc.

Best,
Elsaid

--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/F5D22D34-7AA8-4335-B3AC-2611E6AFBE0B%40gmail.com.

Eric Irrgang

unread,
Feb 15, 2021, 9:29:24 AM2/15/21
to hoomd...@googlegroups.com
This is more than one question. I can try to answer the first.
>
> closing the file means s.close()? still empty file.

Closing the file is not the problem. I was just pointing out that it is good practice to manage the point at which the file is closed.

The file is empty because you have not written anything to it.

If your intention is to write the snapshot to the file, you should take a look at https://gsd.readthedocs.io/en/stable/hoomd-examples.html#write-frames-to-a-gsd-file
You need to hold the snapshot and the open file in separate variables and write (such as with `append`) the snapshot to the file.

>
> I tried to create_lattice, but I failed in writing the particles into it as I want to write two spheres [A,diameter1,charge1,N1] and [B,diameter2,charge2,N2], and the positions of the two types of sphere conflict with each other.

I don't know what you mean. Could you please post a separate question showing what you tried to execute, the difference between your expectations and observations, and including copies of any errors you encountered?

> Note: "I got an error that hoomd has no attribute 'hpmc'" so I tried to import it import hoomd.hpmc.

That sounds correct. Was there a problem?

Best,
Eric

Elsaid Younes

unread,
Feb 15, 2021, 12:04:43 PM2/15/21
to hoomd...@googlegroups.com
Hi,

Thanks for your reply. I think the first thing I do wrong is to write the description to unit cell: uc = hoomd.lattice.unitcell(
N = the whole number of the particles that exist in the system('A','B'),
I can not define the positions of two types of particles in the box);
I think I should build the model then place the particles into it before I write gsd file?
I did try a lot to write snapshot, but I faced the same problem.
Please check the last lines of the attached script I called box and particles properties.

import gsd.hoomd
import numpy as np
import hoomd
import hoomd.hpmc


hoomd.context.initialize("--mode=cpu")


uc = hoomd.lattice.unitcell(N = 2940,
a1 = [906,0,0],
a2 = [0,906,0],
a3 = [0.0,906],
dimensions = 3);
 
system = hoomd.init.create_lattice(unitcell=hoomd.lattice.sc(a=2.3), n=1)


s = gsd.hoomd.Snapshot()
s.particles.N =2940
s.particles.diameter = [150.0]
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [0]
s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)


mc = hoomd.hpmc.integrate.sphere(seed=4552367,d=0.9,a=0)
mc.shape_param.set ('A', diameter = 150, orientable = False)

s = gsd.hoomd.open(name='file_b.gsd', mode='wb')
s.append
print(system.box)
print(system.particles)

OUTPUT:
notice(2): Group "all" created containing 1 particles
Box: Lx=2.3 Ly=2.3 Lz=2.3 xy=0.0 xz=0.0 yz=0.0 dimensions=3
Particle Data for 1 particles of 1 type(s)

Best,
 Elsaid

--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.

Joshua Anderson

unread,
Feb 15, 2021, 3:41:43 PM2/15/21
to hoomd...@googlegroups.com
Elsaid,

If you are trying to write out the gsd snapshot that you create in your code snippet, try this complete script:

import gsd.hoomd
import numpy as np

s = gsd.hoomd.Snapshot()
s.particles.N =2940
s.particles.diameter = [150.0]*2940
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [0]*2940
s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)

with gsd.hoomd.open(name='file.gsd', mode='wb') as f:
f.append(s)

This will write the positions you define to a gsd file. Using numpy and whatever code you write, you can set the position and typeid of all N particles in the simulation box.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan
> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/CAO9cOeCw6s8OFHzT1HdNxBZPeeh2c1EvXWMe8xVEc%2BNjCfsgkQ%40mail.gmail.com.

Elsaid Younes

unread,
Feb 16, 2021, 5:14:01 AM2/16/21
to hoomd...@googlegroups.com
Hi,

I want the particles to be spheres distributed as their written position, and after that, I need to add another type of sphere with a different number, diameter and charge, but the diameter is the only shape parameter allowed in hpmc.integrator. (2940) are just the counter ions.


import gsd.hoomd
import numpy as np

s = gsd.hoomd.Snapshot()
s.particles.N =2940
s.particles.diameter = [4.0]*2940

s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [0]*2940
s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)
s.particles.change = 1


with gsd.hoomd.open(name='file.gsd', mode='wb') as f:
    f.append(s)

GSD FILE =>
image.png


Best,
Elsaid

Joshua Anderson

unread,
Feb 16, 2021, 6:59:52 AM2/16/21
to hoomd...@googlegroups.com
Elsaid,

GSD allows you to write per-particle values for position, orientation, typeid, mass, charge, diameter, body, moment_inertia, velocity, angmom, and image.
https://gsd.readthedocs.io/en/stable/python-module-gsd.hoomd.html#gsd.hoomd.ParticleData

If you want to add additional particles, then change the value you assign to s.particles.N, the length of the per particle lists/arrays and assign the per-particle values as you see fit. There are so many different ways that users initialize their systems that HOOMD cannot possibly provide built-in initialization mechanisms for all of them. You need to write your own.

HPMC stands for hard particle Monte Carlo. It is not an appropriate simulation method for models with long range electrostatic forces.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

> On Feb 16, 2021, at 5:13 AM, Elsaid Younes <elk...@gmail.com> wrote:
>
> Hi,
>
> I want the particles to be spheres distributed as their written position, and after that, I need to add another type of sphere with a different number, diameter and charge, but the diameter is the only shape parameter allowed in hpmc.integrator. (2940) are just the counter ions.
>
>
> import gsd.hoomd
> import numpy as np
>
> s = gsd.hoomd.Snapshot()
> s.particles.N =2940
> s.particles.diameter = [4.0]*2940
> s.configuration.box = [906.0,906.0,906.0,0,0,0]
> s.particles.typeid = [0]*2940
> s.particles.position = np.linspace([2.0,2.0,2.0], [904.0,904.0,904.0], 2940)
> s.particles.change = 1
>
> with gsd.hoomd.open(name='file.gsd', mode='wb') as f:
> f.append(s)
>
> GSD FILE =>
> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/CAO9cOeA6QpO%3Dk_wT6SuoWcaLmcPT9AJ1XeBWVY5oNHhzcJCcag%40mail.gmail.com.

Elsaid Younes

unread,
Feb 16, 2021, 7:43:14 AM2/16/21
to hoomd...@googlegroups.com
Hi,

Bellow is GSD file produced from the script in the previous message.
 
image.png
How can I make particles as spheres inside the box?

Best regards,
Elsaid

Joshua Anderson

unread,
Feb 16, 2021, 8:50:32 AM2/16/21
to hoomd...@googlegroups.com
Elsaid,

Note that your numpy.linspace call places particles on a diagonal starting at 2,2,2 and ending at 904,904,904. These appear as a dotted line in your screenshot. Try zooming in and maybe they will look like spheres.

Are you working in a research group? If yes, many of your questions on this list would be best answered/taught by your advisor or experienced group members. We are here to answer specific questions on using HOOMD and GSD. Questions on what simulation models to use, initialization protocols specific to your research field, and how to use other software (i.e. numpy, OVITO) are outside the scope of this list.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

> On Feb 16, 2021, at 7:43 AM, Elsaid Younes <elk...@gmail.com> wrote:
>
> Hi,
>
> Bellow is GSD file produced from the script in the previous message.
>
> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/CAO9cOeARsjw5B_0vbtTTfX9AoEN4KQb5GrL2%2BPw0jEZ-Ce10qg%40mail.gmail.com.

Elsaid Younes

unread,
Feb 16, 2021, 10:30:58 AM2/16/21
to hoomd...@googlegroups.com
Hi,

Unfortunately, I am working alone. This group is almost the only source. I can have seen that my questions are primitive, but I have been searching for something like this for years.
Can you tell me how can I put all the particles inside the box(the box coordinates should be 906/906/906)?

Best,
Elsaid

Joshua Anderson

unread,
Feb 16, 2021, 10:38:59 AM2/16/21
to hoomd...@googlegroups.com
Elsaid,

Unfortunately, this e-mail group cannot serve as a mentor to you even if you are not a member of a research group. We can only answer specific questions on the use of HOOMD and GSD.

HOOMD boxes range from -L/2 to L/2.

There is more information in the tutorial on initializing system state: https://hoomd-blue.readthedocs.io/en/latest/tutorial/00-Introducing-HOOMD-blue/03-Initializing-the-System-State.html
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

> --
> You received this message because you are subscribed to the Google Groups "hoomd-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/CAO9cOeC9fi1TSdu3g9-q37z9t%3D%3Dvxk6YAD_CP72_brosZ38PHQ%40mail.gmail.com.

Elsaid Younes

unread,
Feb 22, 2021, 10:39:19 AM2/22/21
to hoomd...@googlegroups.com
Hey!

I am now struggling to put 2 particles in the snapshot. I do not know how to write two particles with no conflict in their position. (for the perfect situation I want to add N particle with a bigger diameter, and every one particle surrounded with n number of the first type)
Note: I successfully wrote the two particles but every particle in one gsd file.
Below is the script which has one type of particle:

import gsd.hoomd
import numpy as np

data_c = np.linspace([-451,-451,-451], [451,451,451], 2940)
np.random.shuffle(data_c[:, 0])
np.random.shuffle(data_c[:, 1])
s = gsd.hoomd.Snapshot()
s.particles.N = 2940

s.particles.diameter = [4.0]*2940
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [0]*2940
s.particles.position = data_c
with gsd.hoomd.open(name='file_c.gsd', mode='wb') as f:
    f.append(s)


Best,
Elsaid

Eric Irrgang

unread,
Feb 22, 2021, 5:43:24 PM2/22/21
to hoomd...@googlegroups.com


On Mon, Feb 22, 2021, 18:39 Elsaid Younes <elk...@gmail.com> wrote:
Hey!

I am now struggling to put 2 particles in the snapshot.

Did you encounter an error? As you say,  the script you include assigns all particles the same type: 0.

I do not know how to write two particles with no conflict in their position. (for the perfect situation I want to add N particle with a bigger diameter, and every one particle surrounded with n number of the first type)

This question is too general to answer.

If you want to initialize a dense packing, you need to come up with some coordinates for a unit cell.

Otherwise, there are many many strategies for initializing lower density systems and then compressing them. (Several are described in hoomd documentation and tutorials.)

The best technique will depend on the target density, the types of particle interactions, other parameters of your research problem, constraints on computing resources, and more challenging emergent details, like the mixing dynamics of your system. 

If you can find any literature investigating a similar simulated system, the methods section or supplemental information should describe how the author prepared their initial system. Then you could ask specific questions related to how best to accomplish the same thing in hoomd.

Best,
Eric

Elsaid Younes

unread,
Feb 23, 2021, 5:09:41 AM2/23/21
to hoomd...@googlegroups.com

Dear Arash and Eric,

@Arash

Thanks, Arash for your advice and script.
I am not sure if your script will work fine for my situation as my target is measuring the radial distribution function to show the effect of electrostatic interactions, and still do not feel free to play with the particles (types and positions)
I will have a look at Molsim GitHub later.

@Eric.

As you see in my script I can integrate one type of particle" 2940 particles" I want to add another 21 particles of type 'B' I want to make every particle of type 'B' surrounded with 140 of 'A'
I could have made two GSD files and merged them in one scene =>
image.png
When I was trying to write bot types in one snapshot I got errors like ValueError: operands could not be broadcast together with shapes (1500,3) (1440,3)
I think on making 21 unit cells with 141 particles 140 'A' +1'B'. (I want the lattice to work as box-no boundary conditions inside the box)
I was advised that hoomd.hpmc is not the appropriate technique to study long-range electrostatic interactions.

Best regards,
Elsaid

Eric Irrgang

unread,
Feb 23, 2021, 10:33:57 AM2/23/21
to hoomd...@googlegroups.com
> As you see in my script I can integrate one type of particle" 2940 particles" I want to add another 21 particles of type 'B' I want to make every particle of type 'B' surrounded with 140 of 'A'

You will have to define for yourself what "surrounded" means. Are you simulating hard colloidal particles with residual charge or point charges in free space? You mentioned "diameter", so I assume you don't mean point charges. Do you need to constraint the small particles to the surface of the larger? Do you know how stiff you need their repulsion to be, and what potential you intend to use to model it?

> I could have made two GSD files and merged them in one scene =>
> <image.png>
> When I was trying to write bot types in one snapshot I got errors like ValueError: operands could not be broadcast together with shapes (1500,3) (1440,3)

Yes, all of the arrays need to account for all of the particles. If you have 2940+21 = 2961 particles, you need to assign 2961 positions and 2961 particle type values. 2940 would be one type and 21 would be the other.

> I think on making 21 unit cells with 141 particles 140 'A' +1'B'.

Okay.

> (I want the lattice to work as box-no boundary conditions inside the box)

I don't understand this comment. Periodic boundary conditions are essential in hoomd simulations. You can define a very large box to simulate an open system, but there are various performance-related considerations, if that is what you need to do. Note that the size asymmetry shown in your image implies you should already be considering https://hoomd-blue.readthedocs.io/en/v2.9.4/nlist.html#lbvh-tree, which should also help in the sparse system if you try to simulate free space.

Depending on the length scale (the size of your modeled particles, screening, etc.) https://hoomd-blue.readthedocs.io/en/v2.9.4/module-md-charge.html#hoomd.md.charge.pppm may be appropriate, and provides some introduction and links.

> I was advised that hoomd.hpmc is not the appropriate technique to study long-range electrostatic interactions.

That is correct.

Best,
Eric

Elsaid Younes

unread,
Feb 23, 2021, 3:19:56 PM2/23/21
to hoomd...@googlegroups.com
Dear Eric,

I am simulating hard colloidal particles with a point charge in water. The small particles (2940) are counter ions, but the large particles(21) are protein micelles treated as hard spheres. I want to model electrostatic potential.
I did mean by the boundary conditions part that I will need to measure the electrostatic potential between the micelle i.e centers of boxes, is that possible?


Best,
Elsaid

--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.

Eric Irrgang

unread,
Feb 24, 2021, 6:43:39 AM2/24/21
to hoomd...@googlegroups.com
> I am simulating hard colloidal particles with a point charge in water. The small particles (2940) are counter ions, but the large particles(21) are protein micelles treated as hard spheres. I want to model electrostatic potential.

"Hard" is a relative term here. :-) Is WCA hard enough for you? An even softer potential may be appropriate. Note that the softer the potential, the longer the time-step you can usually use. Lennard-Jones or shifted-Lennard-Jones are frequently sufficient phenomenological colloid models.

> I did mean by the boundary conditions part that I will need to measure the electrostatic potential between the micelle i.e centers of boxes, is that possible?

I don't know what box the micelles are at the center of. Are you planning to restrain them to lattice sites?

HOOMD is frequently used to study similar questions, but the work I'm familiar with is generally at longer length scales, and usually with substantial implicit solvent for screening. But I suggest you take a look at the papers citing HOOMD to see if there is similar work that you can base your method on.

Maybe someone on this list has something close to your system that they can share.

Best,
Eric

Elsaid Younes

unread,
Feb 25, 2021, 4:42:35 AM2/25/21
to hoomd...@googlegroups.com
Dear Eric,

Can you please comment on the below script:
'M' is micelle with number 1 and a diameter of 150
'A', 'B' is the same with number 70+70

import hoomd

import gsd.hoomd
import numpy as np

hoomd.context.initialize('--mode=cpu')

uc = hoomd.lattice.unitcell(
    N = 141,
    a1 = [328.3888726468733,0,0],
    a2 = [0,328.3888726468733,0],
    a3 = [0,0,328.3888726468733],
    dimensions = 3,
    position = [ [0,0,0]*1,
                np.linspace([-164.19443632343666,-164.19443632343666,-164.19443632343666], [-75,-75,-75], 70)*70,
                np.linspace([75,75,75], [164.19443632343666,164.19443632343666,164.19443632343666],70) *70],
    type_name = ['M','A','B'],
    charge = [-140.0*1, 1.0*70,1.0*70],
    diameter = [150.0*1, 4.0*70, 4.0*70] 

system = hoomd.init.create_lattice(uc, n=21)
with gsd.hoomd.open(name='file.gsd', mode='wb') as f:
    f.append(system)

Best,
Elsaid

--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.

Eric Irrgang

unread,
Feb 25, 2021, 3:56:18 PM2/25/21
to hoomd...@googlegroups.com
Hi Elsaid.

I could be mistaken (I don't have time to check the docs right now) but i don't think the gsd package will know what to do with a hoomd system object. I also don't know whether the snapshot objects are api compatible. There are gsd writing tools in the hoomd package, though. You probably want one of the `dump` commands. 

There are several errors with the array dimensions. You will find such errors faster if you construct numpy arrays at all steps instead of relying on native Python lists. You have some scalars that you multiply when you probably meant to multiply a single element list to generate a longer list (you forgot the []). You have some lists embedded in other lists when you probably meant to concatenate the lists. Presumably, you also intend to provide a 141 element list of particle types, but i don't see that in your script either.

Check out Python's list.append() and list.extend() or numpy's concatenate. Also look up the numpy rules for "broadcasting". It's wonderful.

Good luck!


Elsaid Younes

unread,
Mar 1, 2021, 4:07:45 PM3/1/21
to hoomd...@googlegroups.com
Hi,

Can you please tell e how can I merge the following two GSDs in order to apply electrostatic potential among the big spheres?


import gsd.hoomd
import numpy as np


data_m = np.linspace([-376,-376,-376], [376,376,376], 21)
np.random.shuffle(data_m[:, 0])
np.random.shuffle(data_m[:, 1])



s = gsd.hoomd.Snapshot()
s.particles.N = 21
s.particles.diameter = [150.0]*21
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [1]*21
s.particles.position = data_m
with gsd.hoomd.open(name='file_m.gsd', mode='wb') as f:
    f.append(s)



second one:

import gsd.hoomd
import numpy as np


data_c = np.linspace([-451,-451,-451], [451,451,451], 2940)
np.random.shuffle(data_c[:, 0])
np.random.shuffle(data_c[:, 1])



s = gsd.hoomd.Snapshot()
s.particles.N = 2940
s.particles.diameter = [4.0]*2940
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [0]*2940
s.particles.position = data_c
with gsd.hoomd.open(name='file_c.gsd', mode='wb') as f:
    f.append(s)
   

Best,
Elsaid

Joshua Anderson

unread,
Mar 2, 2021, 5:41:41 AM3/2/21
to hoomd...@googlegroups.com
Elsaid,

We have no built-in tools to combine two GSD files into one. As Eric Irrgang stated:

> Check out Python's list.append() and list.extend() or numpy's concatenate. Also look up the numpy rules for "broadcasting". It's wonderful.

You want to concatenate every per-particle array from one file to the end of those in the other.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/CAO9cOeABh9_WO1OLvJQRDe-JiCkqPTYdx9%2BMLJbObYRHiP6VnQ%40mail.gmail.com.

Elsaid Younes

unread,
Mar 2, 2021, 4:33:58 PM3/2/21
to hoomd...@googlegroups.com
Hi,

I did understand that. I want to know how shall I put every single"type id" in their own positions, if I have two type ids x,y, and I have just four particles. How can I put the parameters generally?
Here is an example where ids are 1,2:

I got this error:

ValueError: setting an array element with a sequence.

The script:


import gsd.hoomd
import numpy as np

s = gsd.hoomd.Snapshot()
s.particles.N = 4
s.particles.diameter = [110.0]*3,[150.0]*1
s.configuration.box = [906.0,906.0,906.0,0,0,0]
s.particles.typeid = [2]*3, [1]*1
s.particles.position =[[-420,-420,-420],[-320,-320,-320],[-200,-200,-200]]*2, [[0,0,0]]*1

with gsd.hoomd.open(name='file_m.gsd', mode='wb') as f:
    f.append(s)


Best,
Elsaid

Michael Howard

unread,
Mar 2, 2021, 6:49:46 PM3/2/21
to hoomd-users
You need to extend or concatenate the lists / arrays, e.g.,

s.particles.diameter = [110.0]*3 + [150.0]*1

Elsaid Younes

unread,
Oct 23, 2021, 1:55:35 PM10/23/21
to hoomd...@googlegroups.com
Dear all,

As I figured out that the particles might be overlapped. I do not understand the above tutorial.
What is (m),(K)
N_particles: are the total number of the particles "21+2940"
(L) is supposed to be a constant value and doesn't depend on the spacing.

Best regards,
Elsaid

--
You received this message because you are subscribed to the Google Groups "hoomd-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hoomd-users...@googlegroups.com.

Joshua Anderson

unread,
Oct 25, 2021, 9:10:53 AM10/25/21
to hoomd...@googlegroups.com
Elsaid,

The tutorial https://hoomd-blue.readthedocs.io/en/latest/tutorial/00-Introducing-HOOMD-blue/03-Initializing-the-System-State.html describes one way to place K*K*K particles in a simple cubic structure. K is any positive integer. The tutorial then selects N_particles from those K*K*K to use when initializing the simulation where the number of particles is commensurate with that of a bcc structure which has 2 * m**3 particles, where m is any positive integer. Here, m and K are the number of unit cells along one axis.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/CAO9cOeBfGy8R3BRitWQQV5msPRa3thLHExA6fpJ%2Befs8wwe4vA%40mail.gmail.com.

Elsaid Younes

unread,
Oct 26, 2021, 8:15:07 AM10/26/21
to hoomd...@googlegroups.com
Hi,

I am still confused.
1) what is the relationship between the box length and K and spacing, as the box length should be constant value and does not depend on particles.
2) K*K*K where K is integer. K can not be an integer if I have 21 particles for example, and what is 'm' in that case?

Best regards,
Elsaid

Joshua Anderson

unread,
Oct 26, 2021, 8:31:12 AM10/26/21
to hoomd...@googlegroups.com
Elsaid,

1) Yes, the box length depends on the particles in periodic structures with periodic boundary conditions. I suggest you review textbook material on crystals and solid state physics to resolve your confusion.

2) The code in the tutorial is an *example*. If it does not apply to your case, then do not use it. You could type the coordinates of your 21 particles, you could use a tool like packmol to place them, you could write a script to place them, or any other solution you prefer to generate the initial positions of your particles.
------
Joshua A. Anderson, Ph.D.
Research Area Specialist, Chemical Engineering, University of Michigan

> To view this discussion on the web visit https://groups.google.com/d/msgid/hoomd-users/CAO9cOeABa1aWGw6KT4gV%2BmBJC5XqDU-ufYu277W-kwV%2BkuiQAA%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages