Skip to content

Commit 7c9d3c6

Browse files
author
HYB777
committed
hook design
1 parent 87e7568 commit 7c9d3c6

File tree

318 files changed

+3733
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+3733
-0
lines changed

model-based-design/hook_design/IPOPT.out

Lines changed: 273 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Hook Design
2+
3+
The objective in the hook design is to identify an optimal shape that enhances the stiffness
4+
while adhering to specific volume constraints and loads. This can be achieved by minimizing
5+
the strain energy.
6+
7+
## Shape Sampling
8+
9+
We model the half of the hook by lofting 11 2D sections along a guideline, see Appendix G for more details.
10+
For maintaining a naturalistic semblance characterized by smoothness and minimal undulation,
11+
we apply mean filter to each section once or two at random (each section are generated independently and randomly),
12+
considering its neighboring sections.
13+
14+
Finally, we generate a total of 222,141 shape data points. All data are stored in [data](data).
15+
16+
## High-fidelity Physical Model Learning
17+
18+
We employ the mean-teacher-based active learning algorithm on this dataset, to select 50,000 shapes
19+
for labeling and train the physical model, the corresponding labels are obtained by COMSOL.
20+
21+
Run the following code under the directory [mean-teacher-al](mean-teacher-al).
22+
23+
```
24+
python main.py
25+
```
26+
27+
## Shape Anomaly Detection
28+
29+
Firstly, run the following code to compute the intrinsic dimension.
30+
31+
```
32+
python lpca.py
33+
```
34+
35+
The results should be 68 (round up). We choose 68 as the dimension of the latent space in
36+
the auto-encoder.
37+
38+
Run the following code for training.
39+
40+
```
41+
python main_ae.py --embed-dim 68
42+
```
43+
44+
The trained model are stored in [results_aeID=68](shape-anomaly-detection/results_aeID=68).
45+
46+
## Numerical Optimization
47+
48+
We perform two kinds of optimization problem.
49+
50+
* P1: $\min E$ s.t. $V\leq0.5V_{\text{init}}$
51+
* P2: $\min V$ s.t. $E\leq0.5E_{\text{init}}$
52+
53+
Run the following code
54+
55+
```
56+
python shape_opt_pysparse.py --prob minEconV # problem 1
57+
58+
python shape_opt_pysparse.py --prob minVconE # problem 2
59+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:d0fe9b642359e81f26d0974966a5daef0ea3e3cb0e2bbea9b79baf33c56c9cd3
3+
size 12665079
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:0c3db8073bc033f72c3c2550dd8515901545f234b716784ac7fb97628ce02741
3+
size 101319387
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:0928d38368881c6e3df45ce06e3ba0d57b887560b84816b8c827c74b61b15d49
3+
size 12665079
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:9f34dcac26f1ecfca0be8305efc1db689a4d3de49a6b2b44316e82786b446898
3+
size 126648667
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import numpy as np
2+
import torch
3+
import scipy.io as scio
4+
from torch.utils.data.dataset import Dataset
5+
6+
7+
def mat2npy(mat_str_list):
8+
mat_list = [scio.loadmat(it) for it in mat_str_list]
9+
scales = np.vstack([it['scales'] if 'scales' in it.keys() else it['scales_i'] for it in mat_list])
10+
sections_pts = np.vstack([it['section_pts'].reshape(-1, 5*10) if 'section_pts' in it.keys() else it['section_pts_i'].reshape(-1, 5*10) for it in mat_list])
11+
guide_pts = np.vstack([it['guide_pts'] if 'guide_pts' in it.keys() else it['guide_pts_i'] for it in mat_list])
12+
labels = np.vstack([it['results'] if 'results' in it.keys() else it['results_i'] for it in mat_list])
13+
params = np.hstack([scales, sections_pts, guide_pts])
14+
return params, labels
15+
16+
17+
class DataLoaderFit(Dataset):
18+
def __init__(self, params, labels):
19+
"""
20+
:param params: (N, 11 + 11*5 + 8) [scales, sections_pts, guide_pts]
21+
:param labels: (N, 2)
22+
"""
23+
super(DataLoaderFit, self).__init__()
24+
25+
self.data = torch.from_numpy(params).float()
26+
self.labels = torch.from_numpy(labels).float()
27+
28+
def __len__(self):
29+
return len(self.labels)
30+
31+
def __getitem__(self, item):
32+
data = self.data[item]
33+
label = self.labels[item]
34+
35+
return data, label
36+
37+
38+
class DataLoaderAE(Dataset):
39+
def __init__(self, params):
40+
"""
41+
:param params: (N, 11 + 11*5 + 8) [scales, sections_pts, guide_pts]
42+
"""
43+
super(DataLoaderAE, self).__init__()
44+
45+
self.data = torch.from_numpy(params).float()
46+
47+
def __len__(self):
48+
return len(self.data)
49+
50+
def __getitem__(self, item):
51+
52+
data_tensor = self.data[item]
53+
54+
return data_tensor
55+
56+

0 commit comments

Comments
 (0)