Read particle data from csv

53 views
Skip to first unread message

simboys

unread,
Jul 29, 2024, 8:59:42 AM7/29/24
to ProjectChrono
Hi,

    I hava a sphere paritcle data contain (x, y, z, radius), from the ReadClumpXyzFromCsv function can only import the sphere particle position, how to set the sphere radius?

Best regards,
Wenxuan XU

Ruochun Zhang

unread,
Jul 31, 2024, 1:33:14 AM7/31/24
to ProjectChrono
Hi Wenxuan,

Sphere radius is a part of the clump template data. That is, in DEME, you need to first define clump templates (could be a single-sphere clump if you need it), then instantiate those clump templates to create the particles in simulations. So in your case, you need to process the file to derive the types of clumps (or say in your case, the distinct radii that the spheres might have), then load these as templates, then instantiate their respective clump templates at the xyz locations you have in the file.

I know it could be a bit problematic your radii is continuous, and in that case you should emulate a continuious range of radii with a discrete set of different radii. The DEME data structure potentially allows for storing continuous clump shape information, however the APIs needed are not implemented yet so right now, it can't be done easily.

Note that if the data file is the output of another DEME simulation, then instead, the real issue here is that you should have generated this data file with WriteClumpFile rather than WriteSphereFile. The former will write each clump in each line (rather than breaking up each clump and write component spheres to the file like the latter), and it contains the name for the clump template that the current particle belongs to. That file is easier to use to restart a simulation, and you can refer to how it is done in DEMdemo_GRCPrep_Part2.

Thank you,
Ruochun

simboys

unread,
Jul 31, 2024, 2:57:35 AM7/31/24
to ProjectChrono
Hi, Ruochun

       Thank you for your reply. My goal is to import nearly 100,000 spherical particles into DEME, and the radius of each spherical particle is different. When I use the following code to import 100,000 spherical particles into DEME, it prompts that DEME can only support a maximum of 255 templates. In other words, can I specify a spherical particle template with a fixed radius and then set different scaling ratios to generate particles?
auto data_xyzr = DEMSim.ReadClumpFloat4FromCsv("../data/clumps/Hopper.csv",
OUTPUT_FILE_X_COL_NAME,
OUTPUT_FILE_Y_COL_NAME,
OUTPUT_FILE_Z_COL_NAME,
OUTPUT_FILE_R_COL_NAME,
OUTPUT_FILE_CLUMP_TYPE_NAME
);

std::cout << data_xyzr.size() << " Data points are loaded from the external list." << std::endl;

for (unsigned int i = 0; i < data_xyzr.size(); i++)
{
char t_name[20];
sprintf(t_name, "%d", i);

float radius = data_xyzr[std::string(t_name)][0].w;
float density = 2500;
float mass = density * 4. / 3. * PI * radius * radius * radius;; // in kg or g
auto sphere_template = DEMSim.LoadSphereType(mass, radius, mat_type_particle);
DEMSim.AddClumps(sphere_template, make_float3(data_xyzr[std::string(t_name)][i].x, data_xyzr[std::string(t_name)][i].y, data_xyzr[std::string(t_name)][i].z));
}


The DEME warning as follow:
WARNING! There are 166245 clump templates loaded, but only 255 templates (totalling 255 components) are jitifiable due to some of the clumps are big and/or there are many types of clumps.
It is probably because you have some objects represented by spherical decomposition (a.k.a. have big clumps).
In this case, I suggest calling DisableJitifyClumpTemplates() before system initialization to use flattened clump templates.

terminate called after throwing an instance of 'std::runtime_error'
  what():  166246 different mass properties (from the contribution of clump templates, analytical objects and meshed objects) are loaded, but the max allowance is 65534 (No.65535 is reserved).
You may avoid this by calling DisableJitifyMassProperties() before system initialization to disable jitification for mass properties
This happened in postResourceGenChecksAndTabKeeping.

Ruochun Zhang

unread,
Jul 31, 2024, 10:52:19 AM7/31/24
to ProjectChrono
You should be able to do that by, well, following the suggestion given by the solver: Calling DisableJitifyClumpTemplates() and DisableJitifyMassProperties() before initialization to let the solver store each individual particle's configuration in a long array, rather than templating them and group identical configurations together. This uses more memory but should be able to accommodate more types of templates.

If you encounter further errors or problems with these options, please discuss them with us on the forum.

Thank you,
Ruochun

Reply all
Reply to author
Forward
0 new messages