Skip to content

Feature request: Composite geometry selections #19

@Ladme

Description

@Ladme

Allow users to combine multiple geometric regions using logical operations (AND, OR) for bond selection. This would enable defining arbitrary selection shapes - for example, requiring a bond to be inside both a cuboid and a sphere, or inside either of two separate cuboids.

TODO

  • Check that gorder's architecture can support composite geometry selections
  • Decide on the YAML representation
  • Implement YAML parsing and deserialization
  • Implement the selection logic
  • Add tests, incl. for edge cases (e.g. overlapping regions, empty selections)
  • Update documentation and add examples
  • Update pygorder to include composite geometry selections.
  • (Optional) Update GUIorder.

Design options

Option 1: YAML tags

Extend the existing tag-based syntax with !Or and !And operators:

geometry: !Or
  - !And
    - !Cuboid
      x: [2.0, 4.0]
      y: [1.0, 5.0]
    - !Sphere
      reference: [3.0, 1.0, 4.0]
      radius: 2.5
  - !Cuboid
    x: [0.0, 1.0]
    z: [0.0, 3.0]

The invert keyword could then alternatively be represented using the !Not tag:

geometry: !Not
  !Cylinder
    radius: 2.5
    orientation: z
    reference: !Center

+ straightforward to implement
+ backward compatibility is easy to maintain (bare shapes work unchanged)
− prefix notation is hard to read, understand, and reason about, especially for complex expressions

Option 2: Named regions with a logical expression

regions:
  A: !Cuboid
    x: [2.0, 4.0]
    y: [1.0, 5.0]
  B: !Sphere
    reference: [3.0, 1.0, 4.0]
    radius: 2.5
  C: !Cuboid
    x: [0.0, 1.0]
    z: [0.0, 3.0]

geometry: "(A and B) or C"

+ very intuitive to read and write
− requires a custom parser for the logical expression
geometry keyword would need to support both a single region and an expression string for backward compatibility
− does not fit the current YAML structure

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions