multisphere clump generated at a pre-specified location

Submitted by zhou_yu on Wed, 04/06/2016 - 12:15

can the multisphere clump generated at a specified location?

richti83's picture

richti83 | Wed, 04/06/2016 - 15:03

no, but I hacked the fix_insert_pack to do so:
line 134ff

else if (strcmp(arg[iarg], "atP") == 0) {
if (iarg + 4 > narg) error->fix_error(FLERR, this, "");
px_ = atof(arg[iarg + 1]);
py_ = atof(arg[iarg + 2]);
pz_ = atof(arg[iarg + 3]);
insert_at = true;
iarg += 4;
hasargs = true;
} else if(strcmp(style,"insert/pack") == 0)

line 437ff

if(all_in_flag) ins_region->generate_random_shrinkby_cut(pos,rbound,true);
else if (insert_at) {
pos[0] = px_;
pos[1] = py_;
pos[2] = pz_;
}

don't forget to declare the global variables in the header file !
Than you can use atP $x $y $z inside the input deck in a loop

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

zhou_yu | Fri, 04/08/2016 - 15:42

I tried to modify the source code but there were errors when make fedora. My programming skill is poor and thanks for your hearty assistance. Hope this will help others as well.

richti83's picture

richti83 | Fri, 04/08/2016 - 17:10

Can't help without exact error, crystel ball is broken, did you added flag and position variables to header file?

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

zhou_yu | Mon, 04/11/2016 - 16:50

I am not quite familiar with C++. I followed with your hint and added the argument "atP" as follow (from line 132ff, a little different from your hint).

} else if (strcmp(arg[iarg], "atP") == 0) {
if (iarg + 4 > narg) error->fix_error(FLERR, this, "");
px_ = atof(arg[iarg+1]);
py_ = atof(arg[iarg+2]);
pz_ = atof(arg[iarg+3]);
insert_at = true;
iarg += 4;
hasargs = true;
} else if(strcmp(style,"insert/pack") == 0)
error->fix_error(FLERR,this,"unknown keyword");
}

Then I add the position ( the adjacent lines included):

do
{

if(all_in_flag) ins_region->generate_random_shrinkby_cut(pos,rbound,true);
else if (insert_at) {
pos[0] = px_;
pos[1] = py_;
pos[2] = pz_;
}
else ins_region->generate_random(pos,true);
ntry++;
}
while(ntry < maxtry && domain->dist_subbox_borders(pos) < rbound);

if(ntry == maxtry) break;

the above shows the changes in cpp file, and I am not sure what needs to be added into the head file.
I added some as follows:

double atP;
double pos[3];
double px_;
double py_;
double pz_;
int insert_at;

These changes do make the 'make fedora' work with no error, and the 'lmp_fedora' can check the argument 'atP', but the following position is ignored, just seems like the 'atP 0 0 0' is skipped.
Could you help me and give more hints?
Thanks a lot.

richti83's picture

richti83 | Mon, 04/11/2016 - 19:44

I'm not in the office so I try to help from memory:

//double atP; //<- not used
//double pos[3]; //<-- local definded in insert_pack::x_v_omega()
double px_;
double py_;
double pz_;
int insert_at; // should be bool but doesn't matter

Maybe a make clean-all && make fedora is necessary ...

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

zhou_yu | Tue, 04/12/2016 - 08:25

Now the lmp_fedora works well. Because I didnot noticed that the all_in_flag should be no.
Thank you !

Westbrink | Fri, 04/08/2016 - 15:09

Hi I am a very new LIGGGHTS user and have to use multispheres.
Due to this it is necessary to "place" these multispheres at a distinct position.

I tried your code and re-complied via "make fedora". There are no errors etc, but there will be no atoms inserted
Did I anything wrong?
Do you have a hint?

region insert_box1 block -5 5 -10 10 10.1 15 units box
fix ins1 all insert/pack seed 1001 distributiontemplate msd1 insert_every once overlapcheck yes particles_in_region 10 atP 0 0 0 region insert_box1 ntry_mc 10000
region insert_box2 block -5 5 -10 10 10.1 15 units box
fix ins2 all insert/pack seed 1001 distributiontemplate msd2 insert_every once overlapcheck yes particles_in_region 20 region insert_box2 ntry_mc 10000

PS: The "old" insert/pack does not work anymore

richti83's picture

richti83 | Fri, 04/08/2016 - 17:07

Your z Position is outside the Region.

Check if the reg used in create box command includes the atP coords otherwise the newly created particles are deleted asap.
Set particles in Region for first insert to 1 otherwise you will create 10 totally overlapping clumps and this is Bad.

Maybe the lines i mentioned are not exact because of my changes check the sourrounding lines of code.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

Westbrink | Mon, 04/11/2016 - 09:13

Thanks a lot.
It was a stupid mistake but now it works very well.

Thank you for publishing your code.

Westbrink | Wed, 09/28/2016 - 15:13

Hi all,

I installed a new simulation machine with the newest version of LIGGGHTS and implemented the changed code into the insert/pack command.
If my code has mutiple "run" commands, the particles are unexpetly delted after the second run command.

Does anyone else has similiar problems and a solution?

Regards,
Westbrink

richti83's picture

richti83 | Sat, 10/01/2016 - 22:30

I guess my patch does not check if the insert position is inside the subdomain of a specific process (as before 3.5.0 we only have had single core multispheres), so every instance inserts at "atP". Try fix .. multisphere/nointegration and check dump file if there are particles at exact same position (this will lead to 100% overlap -> a=NAN -> f=NAN -> particles flying away in 1 step to nirvana)
In my case changing

else if(ntotal_region > 0)
{
MPI_Sum_Scalar(np_region,world);
if (insert_at) ninsert_this = 1;
else ninsert_this = ntotal_region - np_region;
insertion_ratio = static_cast(np_region) / static_cast(ntotal_region);
}

in fix_insert_pack.cpp line 320ff
helped.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact