fast_cd_sim
fast_cd_sim
Fast Complementary Dynamics Simulation, implementation of https://www.dgp.toronto.edu/projects/fast_complementary_dynamics_site/
Source code in src\fast_cody\fast_cd_sim.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
__init__(V, T, B, l, J, mu=10000.0, rho=1000.0, h=0.01, max_iters=30, threshold=1e-08, read_cache=False, cache_dir='', Aeq=None, write_cache=False)
Initializes a Fast Complementary Dynamics Simulation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V |
(n, 3) float numpy array
|
Vertex positions |
required |
T |
(F, 4) int numpy array
|
Tet indices |
required |
B |
(3n, m) float numpy array
|
Subspace matrix |
required |
l |
(F, 1) int numpy array
|
Cluster labels |
required |
J |
(3n, 12b) float numpy array
|
LBS rig jacobian |
required |
mu |
float
|
First lame parameter (default=1e5) |
10000.0
|
rho |
float
|
Density (default=1) |
1000.0
|
h |
float
|
Timestep (default=1e-2) |
0.01
|
max_iters |
int
|
Maximum number of iterations for the local-global solver (default=30) |
30
|
threshold |
float
|
Convergence threshold for local global solver (default=1e-8) |
1e-08
|
read_cache |
bool
|
Whether to read simulation precomp from cache (default=False) |
False
|
cache_dir |
str
|
Directory to read/write cache from/to (default="") |
''
|
Aeq |
(c, m) float numpy array
|
Constraint matrix (default empty, untested yet) |
None
|
write_cache |
bool
|
Whether to write simulation precomp to cache (default=False) |
False
|
Source code in src\fast_cody\fast_cd_sim.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
step(p, state, z=None, f_ext=None, bc=None)
Steps simulation state forward
Parameters:
Name | Type | Description | Default |
---|---|---|---|
p |
(12b, 1) float numpy array
|
Next state of the rig parameters |
required |
state |
fast_cd_state
|
Current state of the simulation |
required |
f_ext |
(m, 1) float numpy array
|
External force (default=0) |
None
|
bc |
(c, 1) float numpy array
|
Boundary constraints (default=None). Only valid if fast_cd_sim.Aeq is non-empty |
None
|
Returns:
Name | Type | Description |
---|---|---|
z_next |
(m, 1) float numpy array
|
Next state of the reduced secondary motion sim |
Source code in src\fast_cody\fast_cd_sim.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
fast_cd_state
Bases: cd_sim_state
Simulation state for a Fast Complementary Dynamics Simulation
For Fast CD, the state is comprised of 4 quantities: z_curr: the current state of the reduced secondary motion p_curr: the current state of the rig parameters z_prev: the previous state of the reduced secondary motion p_prev: the previous state of the rig parameters
Source code in src\fast_cody\fast_cd_sim.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
__init__(z_curr, p_curr, z_prev=None, p_prev=None)
Sets current and previous simulation states
Parameters:
Name | Type | Description | Default |
---|---|---|---|
z_curr |
(m, 1) float numpy array
|
Current state of the reduced secondary motion sim |
required |
p_curr |
(12b, 1) float numpy array
|
Current state of the rig parameters |
required |
z_prev |
(m, 1) float numpy array
|
Previous state of the reduced secondary motion sim. If None, set to z_curr |
None
|
p_prev |
(12b, 1) float numpy array
|
Previous state of the rig parameter. If None, set to p_curr |
None
|
Source code in src\fast_cody\fast_cd_sim.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
update(z, p)
Updates the simulation state
Parameters:
Name | Type | Description | Default |
---|---|---|---|
z |
(m, 1) float numpy array
|
Next state of the reduced secondary motion sim |
required |
p |
(12b, 1) float numpy array
|
Next state of the rig parameters |
required |
Source code in src\fast_cody\fast_cd_sim.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|