Generate particles from a file with different material properties

Issue
We previously used entity_set to define subset of particles (pset_id) and assign different material_id to each subset.

With the current implementation, the pset_id is assigned at the generator of particles, thus needing multiple files to define multiple pset_ids. I wonder whether there are better ways to have the input files. This is an example of the current implementation, and as you can see, if we have 100 material ids, it would be quite a mess.

  "particles": [
    {
      "generator": {
        "check_duplicates": true,
        "location": "particles-0.txt",
        "io_type": "Ascii2D",
        "particle_type": "P2D",
        "material_id": 0,
        "type": "file",
        "pset_id": 0
      }, 
      "generator": {
        "check_duplicates": true,
        "location": "particles-1.txt",
        "io_type": "Ascii2D",
        "particle_type": "P2D",
        "material_id": 1,
        "type": "file",
        "pset_id": 1
      }
    }
  ],

Hi @ezrayst

Particles can be part of multiple sets. You can use a single generator to read a list of particles, and use entity_sets to define different sets of particles.

    "particle_sets": [
        {
        "id": 0,
        "set": [p0_0, ... , p0_n]
        },
        {
        "id": 1,
        "set": [p1_0, ... , p1_n]
        }
    ],

Could you please explain how material ids and sets were defined previously?

We have one file particles.txt to define all the particles.

We use entity_set to define different pset_id for different particles. Example:

{
	"particle_sets"	:	[
		{
		"id"	:	0,
		"name"	:	"Rolled Fill",
		"set"	:	[0,1,2,3,4,5]
		},
		{
		"id"	:	1,
		"name"	:	"Ground Shale",
		"set"	:	[1690,1691,1692,1693,1694,1695]
		}

For the material definitions, the same is applied suhc as follow:

  "particle": {
    "material_id": 0,
    "particle_type": "P2D",
    "particle_sets": [
      {
      "set_id": 0,
      "name": "Rolled Fill",
      "initialise_material": true,
      "material_id": 0
      },
      {
      "set_id": 1,
      "name": "Ground Shale",
      "initialise_material": true,
      "material_id": 1
      },

I don’t see why the new solution any more difficult than the old one. Your input JSON will have 100 JSON objects, if you have 100 materials. It depends on if the particle_sets are going to be repeated or generator objects. In the old method you’d have to extract the particle coordinates manually, and if you refine or add new particles you’d have to regenerate the particle_sets. In the new method you can have multiple generators and particle sets are created automatically.

But the old one would require one particle file, one stress file and one volume file instead of 100 if we have 100 materials.

Also, currently the volumes and stresses are still defined apart from the generator, should we define them together?