-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
689 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# File: example_domino.yml | ||
# Author: Ryoichi Ando ([email protected]) | ||
# License: Apache v2.0 | ||
|
||
name: domino.ipynb | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
runner: | ||
type: string | ||
required: true | ||
description: 'Runner Name' | ||
|
||
env: | ||
VAST_API_KEY: ${{ secrets.VAST_API_KEY }} | ||
EXAMPLE_NAME: domino | ||
HELPER_PATH: .github/workflows/vast/helper.sh | ||
|
||
jobs: | ||
run: | ||
runs-on: ${{ github.event.inputs.runner }} | ||
steps: | ||
|
||
- name: check out repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: print scene | ||
run: | | ||
echo "Scene: $EXAMPLE_NAME" >> $GITHUB_STEP_SUMMARY | ||
- name: prepare | ||
timeout-minutes: 30 | ||
run: bash $HELPER_PATH create $VAST_API_KEY | ||
|
||
- name: 1st run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 2nd run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 3rd run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 4th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 5th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 6th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 7th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 8th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 9th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: 10th run | ||
run: bash $HELPER_PATH run ${EXAMPLE_NAME}.py | ||
|
||
- name: shutdown | ||
if: always() | ||
run: bash $HELPER_PATH delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "834a079d-fb9f-43e1-95b3-1e373a7096fa", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"from frontend import App\n", | ||
"\n", | ||
"app = App.create(\"domino\")\n", | ||
"V, F, T = (\n", | ||
" app.mesh.cube(Nx=6, Ny=12, Nz=3, size_x=1, size_z=0.2).tetrahedralize().scale(0.3)\n", | ||
")\n", | ||
"app.asset.add.tet(\"block\", V, F, T)\n", | ||
"scene = app.scene.create(\"domino\")\n", | ||
"\n", | ||
"R, minR, d, N, C = 2.5, 1.2, 0.3, 4096, 3\n", | ||
"xz = None\n", | ||
"for i in reversed(range(N)):\n", | ||
" t = 2.0 * C * np.pi * i / N - np.pi / 2\n", | ||
" r = (R - minR) * i / N + minR\n", | ||
" angle = 180 * t / np.pi\n", | ||
" x, z = -r * np.cos(t), r * np.sin(t)\n", | ||
" if xz is None or np.linalg.norm(np.array([x, z]) - xz) > d:\n", | ||
" scene.add(\"block\").at(x, 0, z).rotate(angle, \"y\")\n", | ||
" xz = np.array([x, z])\n", | ||
"\n", | ||
"scene.add(\"block\").at(-0.15, 0.25, -R).rotate(90, \"y\").rotate(-20, \"z\")\n", | ||
"\n", | ||
"gap = app.session.param().get(\"contact-ghat\")\n", | ||
"scene.add.invisible.wall([0, scene.min(\"y\") - 0.5 * gap, 0], [0, 1, 0])\n", | ||
"\n", | ||
"fixed = scene.build().report().shading(shading={\"flat\": True})\n", | ||
"fixed.preview()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5e6f26d9-03d8-4e50-8315-7d41afbc8532", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"param = app.session.param()\n", | ||
"(\n", | ||
" param.set(\"volume-young-mod\", 6000)\n", | ||
" .set(\"volume-poiss-rat\", 0.49)\n", | ||
" .set(\"friction\", 0.1)\n", | ||
" .set(\"min-newton-steps\", 32)\n", | ||
" .set(\"dt\", 0.01)\n", | ||
" .set(\"fps\", 15)\n", | ||
" .set(\"frames\", 180)\n", | ||
")\n", | ||
"\n", | ||
"session = app.session.create(fixed)\n", | ||
"session.start(param).preview()\n", | ||
"session.stream()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f3755897-773b-4541-9d6b-61eca227a9f6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"session.animate()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7338acaa-f007-48c5-94a8-e481dd0f8cfc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# this is for CI\n", | ||
"assert session.finished()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "972f82eb-76bb-4cfc-9d4d-be3f7202131d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if not app.CI:\n", | ||
" # An extremely stiff case with a quadratic barrier\n", | ||
" extreme_param = app.session.param()\n", | ||
" (\n", | ||
" extreme_param.set(\"volume-young-mod\", 1e5)\n", | ||
" .set(\"volume-poiss-rat\", 0.499)\n", | ||
" .set(\"friction\", 0.1)\n", | ||
" .set(\"frames\", 32)\n", | ||
" .set(\"min-newton-steps\", 32)\n", | ||
" .set(\"dt\", 0.01)\n", | ||
" .set(\"fps\", 15)\n", | ||
" .set(\"barrier\", \"quad\")\n", | ||
" )\n", | ||
" quad_session = app.session.create(fixed)\n", | ||
" quad_session.start(extreme_param).preview()\n", | ||
" quad_session.stream()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5c494187-2705-4ce5-abb9-a91f6ce1da33", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if not app.CI:\n", | ||
" quad_session.animate()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "257072c9-f606-494b-b571-3b1d3f9646eb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if not app.CI:\n", | ||
" # The same extremely stiff case with our cubic barrier\n", | ||
" extreme_param.set(\"barrier\", \"cubic\")\n", | ||
" cubic_session = app.session.create(fixed)\n", | ||
" cubic_session.start(extreme_param).preview()\n", | ||
" cubic_session.stream()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5e00dfda-8e70-465c-a60d-0055fce1af31", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if not app.CI:\n", | ||
" cubic_session.animate()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.