Regions NOT forming single region in region union command

i am trying to simulate a lennard-jones gas in two cubical chambers with a cylindrical tunnel in between them to allow particles to go from on compartment to other. i have used the region union command to join the two blocks and cylinder(open 1 open 2, i mean its open on both circular faces). the problem is that particles are not going through the tunnel rather reflecting from the join as if the regions are still separate and just placed together. i don’t understand why the blocks and cylinder are not forming a single region. please help, it’s my undergrad FYP.

From your description I infer that you are trying to use fix wall/region to contain your gas atoms.
That is notoriously tricky, if not impossible, for complex compound regions as you can have plenty of ambiguities about when an atom is inside or outside which sub-region and what that means for the union of the regions.

For such complex regions it is often much easier to build a containment from explicit atoms, e.g. by having a larger region describing the outer dimensions and then deleting atoms only for a subset.

Something like this:

1 Like

thankyou so much @akohlmey , could you please explain the last line a little further. so do i have to define a lattice and then remove some atoms to form a region? can you share the code for the above image you shared. i have already struggled with convex corners due to shape unions.

You cannot create atoms in a region without having a lattice defined

This is not so complicated here because only the outer shape matters for the combined region. Unlike with a wall potential, it does not matter if regions overlap internally.

No. It has been more than a week and my “test folders” have been cleaned up multiple times since then. But there really isn’t much of a problem doing this because you can always visualize what you are doing by writing out the current state with “write_dump” and then approach this in steps. The deletion of atoms can be done in multiple chunks and you don’t have to worry much about overlaps (again).

If this still seems too complicated to you, you can approach this differently and use a CAD software (e.g. one suitable for 3d-printing) to create your shape as a triangulated mesh and then export it to STL format. Since LAMMPS version 2 June 2022 we support creating atoms from such STL meshes as shown in the visualization below.

@akohlmey thankyou so much for your time. It was too great of you to address the problem in detail. Extremely sorry for the late reply, i was bussy in my exams. I will start it again with the knowledge provided by you and will ask for you help when i get stuck. Again, thankyou.

@akohlmey (pardon me, i have no previous experience with CAD softwares). so it says on the internet that there are solid meshes and surface meshes. do i need to use surface mesh? more precisely, do i need to create the tunnel and box walls as 2D planes or should there be some thickness to them(walls). in the above picture you shared there seems to be some thickness to walls.(or is it only because of atoms having some thickness?)

will LAMMPS just create atoms on the mesh easily with some “create atoms on mesh” command or will i have to use some tricks to achieve the result.

if you know a specific tutorial on creating CAD meshes for use in LAMMPS then please share with me. many thanks.

You need to read all of my responses again and take your time with it. Then you need to read up on the mentioned commands and explanations in the LAMMPS manual.

If the system you want to model is as in my demo animation (and I would assume it is), then you don’t need to use any CAD software (I don’t know how to use 'em either. I just took existing files for the implementation of the create_atoms mesh command), but can build your walls simply with region commands and create_atoms and delete_atoms.

the system i want to model is like the one in the first picture you shared. can i get that file?

I already answered that question. You just didn’t do what I recommended you to do (read through all my previous responses). This is a behavior I strongly dislike. If you want me to continue responding, you better respect my recommendations.

sorry sir, i apologize. i shall read your instructions again.

greetings @akohlmey, sir i read through your instructions and learned to create an stl file and created one. i have run into a new problem. lammps is not creating atoms on the triangle mesh even though everything seems fine and it doesnt show any error.
i have used the following lines in the code,

(
region myreg block -100 100 -100 100 -100 100
create_box 2 myreg
lattice sc 1 origin 0.0 0.0 0.0

create_atoms 1 random 150 341341 myreg
create_atoms 2 mesh boxcone.stl meshmode qrand 0.1 units box
)
lammps is showing the following in command prompt windows 10,
(
Reading STL object boxcone ▬☻ from text file boxcone.stl
Created 0 atoms
)
so it’s not creating (type 2) atoms on the mesh and its showing the type 1 atoms roaming around in the region block as defined by the velocity distribution. here is a snapshot of the triangulated mesh complex region,


and here is a snapshot from the movie lammps has created,

i have been extremely cautious in reading your instructions but apologies in advance if i missed something.

You only missed the biggest hint of them all: don’t use create_atom with the mesh option when you can do such a simple construct with regions and a combination of create_atoms and delete_atoms. It is not very difficult and you can easily do this in steps and confirm correct execution at every step by using the the write_dump command through visualization. This is how I did the demo example.

Obviously there is something incompatible with your STL file and your create_atoms mesh settings since it doesn’t trigger creating any atoms. However, without any information about that file and actually seeing the file, there is nothing I can provide help with.

ok i will go with that method. thankyou so much for helping out such a dumb dude like me. :blush:

@akohlmey i just came here to say thanks. i have now mastered creating complex shapes with delete and create atoms commands and have created the desired simulation. thankyou.