Update TONR_Linear_Stiffness.py

This commit is contained in:
p15806732 2022-11-04 11:22:44 +08:00
parent 9ac4e07f7a
commit 976d2cb704
1 changed files with 7 additions and 19 deletions

View File

@ -4,14 +4,15 @@
@ Author : Zeyu Zhang
@ Email : zhangzeyu_work@outlook.com
@ Date : 2021-11-17 10:52:26
@ LastEditTime : 2022-08-16 14:45:12
@ FilePath : /Topology_Optimization/Linear_TO/TONR_Linear_Stiffness.py
@ LastEditTime : 2022-10-25 09:31:20
@ FilePath : /ZZY_CODE/Env_JAX/IDRL/Linear_TO/TONR_Linear_Stiffness.py
@
@ Description : Jax+Flax+optax TONR Linear Stiffness Problem
@ Reference :
'''
from pathlib import Path # 文件路径的相关操作
import os
from pathlib import Path
import sys
import pandas as pd
import xarray
@ -25,12 +26,10 @@ import TO_Train
import jax.numpy as jnp
from jax import random
from jax.config import config
config.update("jax_enable_x64", True) # 对计算精度影响很大
sys.path.append(
'/home/zzy/ZZY_CODE/Env_JAX/Topology_Optimization/Linear_TO')
config.update("jax_enable_x64", True)
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
here = Path(__file__).resolve().parent
design_condition = 1
if design_condition == 1:
problem = TO_Problem.cantilever_single()
@ -78,15 +77,4 @@ if __name__ == '__main__':
plt.show()
ds_TopOpt.design.sel(step=obj_min_index).plot.imshow(x='x', y='y', size=2,
aspect=2.5, col_wrap=2, yincrease=False, add_colorbar=False, cmap='Greys')
def save_gif_movie(images, path, duration=200, loop=0, **kwargs):
images[0].save(path, save_all=True, append_images=images[1:],
duration=duration, loop=loop, **kwargs)
# images = [
# TO_Support.image_from_design(design, problem)
# for design in ds.design.sel(model='DL_TO')[:150]
# ]
# save_gif_movie([im.resize((5*120, 5*20)) for im in images], 'movie.gif')
aspect=2.5, col_wrap=2, yincrease=False, add_colorbar=False, cmap='Greys')