-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
push to main for code release week 3 (#42)
* delete odb for veni sve simulation * smaller radius threshold * reduce log info for microstructure * add asca rve * naming of pp/pe mixture * add cddm with f3dasm * modify the bash script * handling errors for pp/pe mixture class * cddm data * flake8 test
- Loading branch information
1 parent
9508af1
commit 3a2f0cf
Showing
19 changed files
with
13,644 additions
and
47 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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
from .asca_rve import ASCA_RVE | ||
from .cddm_rve import CDDM_RVE | ||
from .hollow_plate_sve import (ElasticRegularLoads, VonMisesPlasticPathLoads, | ||
VonMisesPlasticRegularLoads) | ||
from .veni_nocohesive_rve import VeniNoCohRVE | ||
from .pppe_no_cohesive_rve import PPPEMixtureNoCohesive |
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,252 @@ | ||
# Modules | ||
# ============================================================================= | ||
# Standard | ||
import logging | ||
import os | ||
import time | ||
from typing import Any | ||
|
||
import rvesimulator | ||
from rvesimulator.abaqus2py.abaqus_simulator import AbaqusSimulator | ||
from rvesimulator.additions.hardening_law import LinearHardeningLaw | ||
from rvesimulator.microstructure.circle_particles import CircleParticles | ||
|
||
from .shared_functionalities import SimulationBase | ||
|
||
# Authorship & Credits | ||
# ============================================================================= | ||
__author__ = "Jiaxiang Yi ([email protected])" | ||
__credits__ = ["Jiaxiang Yi"] | ||
__status__ = "Stable" | ||
# ============================================================================= | ||
|
||
class ASCA_RVE(SimulationBase): | ||
"""Interface between python and abaqus of the ASCA RVE case | ||
Parameters | ||
---------- | ||
SimulationBase : class | ||
base class for simulation | ||
""" | ||
def __init__(self) -> None: | ||
"""Interface between python and abaqus of the ASCA case""" | ||
|
||
logging.basicConfig(level=logging.INFO, filename="asca_rve.log") | ||
self.logger = logging.getLogger("abaqus_simulation") | ||
|
||
self.main_folder = os.getcwd() | ||
self.folder_info = { | ||
"main_work_directory": os.path.join(os.getcwd(), "Data"), | ||
"script_path": os.path.dirname(rvesimulator.__file__) + \ | ||
"/scriptbase", | ||
"current_work_directory": "point_1", | ||
"sim_path": "benchmark_abaqus_scripts.two_materials_rve", | ||
"sim_script": "VonMisesPlasticElasticRegularLoads", | ||
"post_path": "basic_analysis_scripts.post_process", | ||
"post_script": "PostProcess2D", | ||
} | ||
|
||
|
||
def update_sim_info( | ||
self, | ||
size: float = 0.048, | ||
radius_mu: float = 0.003, | ||
radius_std: float = 0.0, | ||
vol_req: float = 0.30, | ||
youngs_modulus_matrix: float = 100.0, | ||
poisson_ratio_matrix: float = 0.3, | ||
youngs_modulus_fiber: float = 1.0, | ||
poisson_ratio_fiber: float = 0.19, | ||
mesh_partition: int = 30, | ||
strain: list = [0.1, 0.0, 0.0], | ||
num_steps: int = 100, | ||
simulation_time: float = 1.0, | ||
num_cpu: int = 1, | ||
platform: str = "ubuntu", | ||
hardening_law: Any = LinearHardeningLaw(), | ||
seed: Any = None, | ||
print_info: bool = False, | ||
) -> None: | ||
"""path dependent rve for cddm | ||
Parameters | ||
---------- | ||
size : float, optional | ||
size of the rve, by default 0.048 | ||
radius_mu : float, optional | ||
radius mean of the rve, by default 0.003 | ||
radius_std : float, optional | ||
radius deviation of the rve, by default 0.0 | ||
vol_req : float, optional | ||
volume fraction requirement, by default 0.30 | ||
youngs_modulus_matrix : float, optional | ||
youngs modulus of the matrix material, by default 100.0 | ||
poisson_ratio_matrix : float, optional | ||
poisson ratio of the matrix material, by default 0.3 | ||
youngs_modulus_fiber : float, optional | ||
youngs modulus of the fiber material, by default 1.0 | ||
poisson_ratio_fiber : float, optional | ||
poisson ratio of the fiber material, by default 0.19 | ||
mesh_partition : int, optional | ||
mesh partition for the edges, by default 30 | ||
strain : list, optional | ||
applied maximum strain, by default [0.1, 0.0, 0.0] | ||
num_steps : int, optional | ||
number of simulation steps, by default 100 | ||
simulation_time : float, optional | ||
total simulation time, by default 1.0 | ||
num_cpu : int, optional | ||
number of cpu used for simulation, by default 1 | ||
platform : str, optional | ||
platform for simulation, by default "ubuntu" | ||
hardening_law : class, optional | ||
hardening law for the simulation, by default LinearHardeningLaw() | ||
seed : Any, optional | ||
seed number, by default None | ||
print_info : bool, optional | ||
print simulation information or not, by default False | ||
""" | ||
|
||
# get simulation information | ||
self.size = size | ||
self.radius_mu = radius_mu | ||
self.radius_std = radius_std | ||
self.vol_req = vol_req | ||
self.youngs_modulus_matrix = youngs_modulus_matrix | ||
self.poisson_ratio_matrix = poisson_ratio_matrix | ||
self.youngs_modulus_fiber = youngs_modulus_fiber | ||
self.poisson_ratio_fiber = poisson_ratio_fiber | ||
self.mesh_partition = mesh_partition | ||
self.strain = strain | ||
self.num_steps = num_steps | ||
self.simulation_time = simulation_time | ||
self.num_cpu = num_cpu | ||
self.platform = platform | ||
self.hardening_law = hardening_law | ||
self.seed = seed | ||
# get hardening law | ||
self.hardening_table = hardening_law.calculate_hardening_table() | ||
|
||
self.sim_paras = { | ||
"size": size, | ||
"radius_mu": radius_mu, | ||
"radius_std": radius_std, | ||
"vol_req": vol_req, | ||
"youngs_modulus_matrix": youngs_modulus_matrix, | ||
"poisson_ratio_matrix": poisson_ratio_matrix, | ||
"youngs_modulus_fiber": youngs_modulus_fiber, | ||
"poisson_ratio_fiber": poisson_ratio_fiber, | ||
"hardening_table": self.hardening_table, | ||
"mesh_partition": mesh_partition, | ||
"strain": strain, | ||
"num_steps": num_steps, | ||
"simulation_time": simulation_time, | ||
"num_cpu": num_cpu, | ||
"platform": platform, } | ||
|
||
# print simulation information to screen | ||
if print_info: | ||
self._print_sim_info(info=self.sim_paras) | ||
|
||
def _get_sim_info(self) -> None: | ||
"""get simulation information""" | ||
self.sim_info = { | ||
"job_name": "asca_rve", | ||
"location_information": self.microstructure.microstructure_info[ | ||
"location_information" | ||
], | ||
"radius_mu": self.microstructure.microstructure_info["radius_mu"], | ||
"radius_std": self.microstructure.microstructure_info[ | ||
"radius_std"], | ||
"len_start": self.microstructure.microstructure_info["len_start"], | ||
"len_end": self.microstructure.microstructure_info["len_end"], | ||
"wid_start": self.microstructure.microstructure_info["wid_start"], | ||
"wid_end": self.microstructure.microstructure_info["wid_end"], | ||
"youngs_modulus_matrix": self.youngs_modulus_matrix, | ||
"poisson_ratio_matrix": self.poisson_ratio_matrix, | ||
"youngs_modulus_fiber": self.youngs_modulus_fiber, | ||
"poisson_ratio_fiber": self.poisson_ratio_fiber, | ||
"mesh_partition": self.mesh_partition, | ||
"hardening_table": self.hardening_table, | ||
"num_steps": self.num_steps, | ||
"simulation_time": self.simulation_time, | ||
"strain": self.strain, | ||
"num_cpu": self.num_cpu, | ||
"platform": self.platform, | ||
} | ||
|
||
def run_simulation( | ||
self, | ||
sample: dict = None, | ||
folder_index: int = None, | ||
sub_folder_index: int = None, | ||
third_folder_index: int = None, | ||
) -> dict: | ||
"""run single simulation | ||
Parameters | ||
---------- | ||
sample : dict, optional | ||
a dict contains the information of design variables | ||
folder_index : int, optional | ||
first folder index, by default None | ||
sub_folder_index : int, optional | ||
second folder index, by default None | ||
third_folder_index : int, optional | ||
third folder index, by default None | ||
Returns | ||
------- | ||
dict | ||
all the simulation results from abaqus | ||
""" | ||
# number of samples | ||
self._create_working_folder( | ||
folder_index, | ||
sub_folder_index, | ||
third_folder_index, | ||
) | ||
os.chdir(self.working_folder) | ||
self.logger.info("working folder: {}".format(self.working_folder)) | ||
# create microstructure | ||
self.microstructure = CircleParticles( | ||
length=self.size, | ||
width=self.size, | ||
radius_mu=self.radius_mu, | ||
radius_std=self.radius_std, | ||
vol_req=self.vol_req, | ||
) | ||
self.microstructure.generate_microstructure(seed=self.seed) | ||
self.microstructure.to_abaqus_format() | ||
self.microstructure.plot_microstructure(save_figure=True, | ||
fig_name="rve_{}.png". | ||
format(self.seed)) | ||
self.vol_frac = self.microstructure.vol_frac | ||
self.logger.info("volume fraction: {}".format(self.vol_frac)) | ||
# update simulation information | ||
self._get_sim_info() | ||
# update the geometry info for microstructure | ||
self._update_sample_info(sample=sample) | ||
# update logger on samples | ||
self.logger.info("============== update info ============") | ||
self.logger.info("sample: {}".format(sample)) | ||
# change folder to main folder | ||
# save microstructure | ||
# update simulation information | ||
self.logger.info("============== Start abaqus simulation ============") | ||
start_time = time.time() | ||
simulator = AbaqusSimulator( | ||
sim_info=self.sim_info, folder_info=self.folder_info | ||
) | ||
# run abaqus simulation | ||
simulator.run() | ||
# get the simulation results back | ||
results = simulator.read_back_results() | ||
end_time = time.time() | ||
self.logger.info("time used: {} s".format(end_time - start_time)) | ||
self.logger.info("============== End abaqus simulation ============") | ||
|
||
# back to main folder | ||
os.chdir(self.main_folder) | ||
|
||
return results |
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
Oops, something went wrong.