Collab4exaNBody / exaNBody

Apache License 2.0
4 stars 0 forks source link

lattice issue when size * repeats is not a multiple of cell_size #67

Closed rprat-pro closed 2 months ago

rprat-pro commented 2 months ago

Replicate bug on exaDEM with spheres and a radius size of 0.5

Bug:

init:
  - lattice:
      structure: SC
      types: [ 0 ]
      size: [ 1.0 , 1.0 , 1.0 ]
      repeats: [ 5, 5 , 5 ]
domain:
  cell_size: 2.0 m
  periodic: [false,true,false]

It fails with repeats: 5, 7 It works with 4, 6, and 10 It works if cell_size = 2.5 It works if the periodic parameter it set to [false,false,false]

It seems that the periodic boundary is not adapted to the size * repeats defined into the lattice operator, as the cell size is not adapted by the lattice operator.

Solution: add a warning maybe ?

carrardt commented 2 months ago

Lattice operator has recently changed for sake of simplicity and robustness regarding definition of domain properties. Previous lattice operator would typically acted as a reader, and defined domain properties by itself, but this lead to number of confusion about domain bounds, grid size and automatically generated transformation. New implementation takes an existing domain and fill it entirely. thus, 1) domain has to be defined before placing lattice operator, and 2) repeats parameter of lattice no longer exists. Here after is an exemple from exaStamp showing how to properly generate data from a lattice on the first run of a simulation and restart from dumps when some exist. Please note that not only the domain is defined, but the 'init_rcb' operator is placed right after in order to properly setup sub domain definition (necessary even if running sequential)

replicate_domain:
  repeat: [ 1 , 1 , 1 ]

input_data:
#
###################################
#  Common part needed both
#  for initial setup and restart
###################################
  - particle_regions:
      - BOX:
          bounds: [ [ 700 ang , 100 ang , 100 ang ] , [ 900 ang , 900 ang , 900 ang ] ]
      - SPHERE:
          quadric:
            shape: sphere
            transform:
              - scale: [ 160 ang , 160 ang , 160 ang ] 
              - translate: [ 180 ang , 180 ang , 180 ang ]
#
  - has_dump_file:
      rebind: { result: has_dump_file }
      body: [ file_exists: { filename: lastLegacyDump } ]
#
################################
#   Initial system setup
# ##############################
  - generate_initial_grid:
      condition: not has_dump_file
      body:
        - message: "Initial run, building system ..."
#     *** Species configuration ***
        - species:
            verbose: false
            species:
              - H: { mass: 1.007 Da , z: 1 , charge: 0.5564 e-  , molecule: H2O }
              - O: { mass: 16 Da    , z: 8 , charge: 0.0 e-     , molecule: H2O }
              - M: { mass: 0.000 Da , z: 0 , charge: -1.1128 e- , molecule: H2O }
              - H2O:
                  charge: 0.0 e-
                  z: 0
                  mass: 0.0 Da
                  rigid_molecule:
                    - O: [  0.00000000 ang ,  0.00000000 ang ,  0.00000000 ang ]
                    - H: [  0.75695033 ang ,  0.58588228 ang ,  0.00000000 ang ]
                    - H: [ -0.75695033 ang ,  0.58588228 ang ,  0.00000000 ang ]
                    - M: [  0.00000000 ang ,  0.15460000 ang ,  0.00000000 ang ]
#     *** Domain configuration ***
        - domain:
            cell_size: 25.0 ang
            grid_dims: [ 40 , 40 , 40 ] # grid dimensions multiplied by cell_size must match bounds' size
            bounds: [ [ 0.0 ang , 0.0 ang , 0.0 ang ] , [ 1000.0 ang , 1000.0 ang , 1000.0 ang ] ]
            periodic: [true,true,true]
            expandable: false
            xform: [ [ 1 , 0, 0 ] , [ 0 , 1 , 0 ] , [ 0 , 0 , 1 ] ] # Identity, unless domain sides' lengths are not multiple of cell_size
        - init_rcb_grid

#     *** Generate lattice with geometrical constraints ***
        - lattice:
            structure: SC
            types: [ H2O ]
            size: [ 3.103 ang , 3.103 ang , 3.103 ang ]
            noise: 0.1 ang
            noise_cutoff: 0.2 ang
            region: SPHERE
#            user_function:
#              wavefront:
#                plane: [ 1 , 0 , 0 , -186.18 ang ]
#                wave: [ 0 , 0.1 , 0 , 0 ]
#                amplitude: 30.0 ang
#     *** Initialize temperature ***
        - random_orient
#
###################################
#  Restart from dump file
###################################
  - read_from_last_dump:
      condition: has_dump_file
      body:
        - message: "Restart from last dump ..."
        - read_dump_rigidmol:
            filename: lastLegacyDump
  - replicate_domain # defaults to 1x1x1, may be overriden by --set-replicate_domain-repeat "[2,1,4]"
carrardt commented 2 months ago

i'm not sure if the new implementation of lattice has been ported to exaNBody main branch, i'm checking this ... and submit a PR if necessary

rprat-pro commented 2 months ago

I'm gonna try to add your operators (domain, lattice and init_rcb_grid) this morning in exaDEM.

We can still use "repeatsé, so it's probably not integrated.

rprat-pro commented 2 months ago

Indeed; init_rcb_grid does not exist:

ERR: Unable to add operator 'init_rcb_grid' to batch
ERR:   | Could not find a operator factory for 'init_rcb_grid' (and no default declaration exists for this name)
lafourcadep commented 2 months ago

Closing this issue due to merged devs that correct this bad behavior.