Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] add particle free in MPM #263

Merged

Conversation

zswang666
Copy link
Collaborator

Feature support for #190

New APIs: mpm_entity.set/get_free.
Non-free particles behave as boundary conditions.

Example code

import genesis as gs

########################## init ##########################
gs.init()

########################## create a scene ##########################

scene = gs.Scene(
    sim_options=gs.options.SimOptions(
        dt=4e-3,
        substeps=10,
    ),
    mpm_options=gs.options.MPMOptions(
        lower_bound=(-0.5, -1.0, 0.0),
        upper_bound=(0.5, 1.0, 1),
    ),
    vis_options=gs.options.VisOptions(
        visualize_mpm_boundary=True,
    ),
    viewer_options=gs.options.ViewerOptions(
        camera_fov=30,
        res=(960, 640),
    ),
    show_viewer=True,
)

########################## entities ##########################
plane = scene.add_entity(
    morph=gs.morphs.Plane(),
)

obj = scene.add_entity(
    material=gs.materials.MPM.Elastic(),
    morph=gs.morphs.Box(
        pos=(0.0, -0.5, 0.25),
        size=(0.2, 0.5, 0.2),
    ),
    surface=gs.surfaces.Default(
        color=(1.0, 0.4, 0.4),
        vis_mode="particle",
    ),
)

########################## build ##########################
scene.build()

################### set active/free/non-fixed particles ####################
pos = obj.get_state().pos.detach().cpu()
is_fixed = pos[:, 1] < (pos.min(0)[0][1] + 0.2)
free = obj.get_free()
free[is_fixed] = 0
obj.set_free(free)

########################## run ##########################
for i in range(1000):
    scene.step()

@zswang666 zswang666 merged commit 35a2fe8 into Genesis-Embodied-AI:main Dec 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants