rvesimulator.microstructure

rvesimulator.microstructure.base

base class of microstructure generator

class MicrostructureGenerator[source]

Bases: object

base class of mirostructure generator

static circle_plot(fibers, length, width, vol_frac, save_figure=False, fig_name='microstrcuture.png', **kwargs)[source]

2d rve plot for circle inclusion

Parameters:
  • fibers (np.ndarray) – fiber locations/positions

  • length (float) – length of the rve

  • width (float) – with of the rve

  • vol_frac (float) – reached volume fraction

  • save_figure (bool, optional) – save figure , by default False

  • fig_name (str, optional) – figure name , by default “microstrcuture.png”

Return type:

None

generate_microstructure(seed=None)[source]

generating micro-structure

Parameters:

seed (Any, optional) – seed generator or number , by default None

Return type:

float

plot_microstructure(save_figure=False, fig_name='RVE.png')[source]

plot figure for RVE

Parameters:
  • save_figure (bool, optional) – save figure or not , by default False

  • fig_name (str, optional) – figure name, by default “RVE.png”

Raises:

NotImplementedError – error report

Return type:

None

rgmsh_plot(save_fig=False, fig_name='rgmsh.png', **kwarg)[source]

contour or voxel plot of the discrete microstructure

Parameters:
  • save_fig (bool, optional) – save figure, by default False

  • fig_name (str, optional) – figure name, by default “rgmsh.png”

Return type:

None

static sphere_coordinate(location_information)[source]

generate coordinate of sphere

Parameters:
  • location_information (np.ndarray) – a numpy array contains center and radius info of a sphere [x, y, z, r]

  • Returns

  • -------ss

  • tuple – coordinate of x, y, z

Return type:

tuple

sphere_plot(fibers, length, width, height, vol_frac, save_figure=False, fig_name='cubic.png')[source]

plot 3d rve with sphere inclusion

Parameters:
  • location_information (np.ndarray) – location information

  • length (float) – length of cubic

  • width (float) – width of cubic

  • height (float) – height of cubic

  • vol_frac (float) – volume fraction

  • save_figure (bool, optional) – a flag to indicate if we want save the figure or not, by default False

  • fig_name (str, optional) – fig name, by default “cubic_rve.png”

Return type:

None

to_abaqus_format(file_name='micro_structure_info.json')[source]

convert microstructure to abaqus format

Parameters:

file_name (str, optional) – file name, by default “micro_structure_info.json”

Raises:

NotImplementedError – error report

Return type:

None

to_crate_format(file_name='microstructure.rgmsh')[source]

convert microstructure to crate format

Parameters:

file_name (str, optional) – _description_, by default “microstructure.rgmsh”

Return type:

None

rvesimulator.microstructure.circle_particles

microstructure generator for 2D RVE with different size of disks/circles

class CircleParticles(length, width, radius_mu, radius_std, vol_req, num_guess_max=50000, num_fiber_max=750, num_cycle_max=15, dist_min_factor=1.1, stirring_iters=100, print_log=False)[source]

Bases: MicrostructureGenerator

2D RVE with different size of disks/circles

Parameters:

MicrostructureGenerator (class) – parent class of microstructure generator

Examples

>>> from rvesimulator.microstructure import CircleParticles
>>> circle_particles = CircleParticles(
...     length=1,
...     width=1,
...     radius_mu=0.1,
...     radius_std=0.01,
...     vol_req=0.1,
... )
>>> circle_particles.generate_microstructure()
>>> circle_particles.plot_microstructure()
>>> circle_particles.to_abaqus_format()
>>> circle_particles.crate_rgmsh()

Initialization

Parameters:
  • length (float) – length of RVE

  • width (float) – width of RVE

  • radius_mu (float) – mean of circle’s radius

  • radius_std (float) – std of circle’s radius

  • vol_req (float) – required volume fraction

  • num_guess_max (int, optional) – maximum guess for fibers, by default 50000

  • num_fiber_max (int, optional) – maximum fiber inside RVE, by default 750

  • num_cycle_max (int, optional) – iteration cycles, by default 15

  • dist_min_factor (float, optional) – distance factor, by default 2.07

__init__(length, width, radius_mu, radius_std, vol_req, num_guess_max=50000, num_fiber_max=750, num_cycle_max=15, dist_min_factor=1.1, stirring_iters=100, print_log=False)[source]

Initialization

Parameters:
  • length (float) – length of RVE

  • width (float) – width of RVE

  • radius_mu (float) – mean of circle’s radius

  • radius_std (float) – std of circle’s radius

  • vol_req (float) – required volume fraction

  • num_guess_max (int, optional) – maximum guess for fibers, by default 50000

  • num_fiber_max (int, optional) – maximum fiber inside RVE, by default 750

  • num_cycle_max (int, optional) – iteration cycles, by default 15

  • dist_min_factor (float, optional) – distance factor, by default 2.07

_core_iteration()[source]

core iteration part of the micro-structure generation method

Return type:

None

static _first_new_fiber(x, y, r, portion)[source]

generate the first new fiber

Parameters:
  • x (float) – x center

  • y (float) – y center

  • r (float) – radius

  • portion (int) – portion of the fiber(1, 2, 4)

Returns:

new fiber

Return type:

np.ndarray

_parameter_initialization()[source]

Initialize the parameters

Return type:

None

_procedure_initialization()[source]

This function is used to generate the first disk and assign the initial values of the algorithm

Return type:

None

_update_fiber_position(new_fiber, iter)[source]

update the fiber position

Parameters:
  • new_fiber (np.ndarray) – the generated new fiber

  • iter (int) – determine the nex fiber should be analysis

Returns:

iter – he updated number of index

Return type:

int

crate_rgmsh(num_discrete=10)[source]

create rgmsh numpy array for crate

Parameters:

num_discrete (int, optional) – number of discrete partition, by default 10

Returns:

2d numpy array that contains the micro-structure information

Return type:

np.ndarray

static fiber_volume(radius)[source]

calculate the fiber volume of the current fiber

Parameters:

radius (float) – radius

Returns:

vol – volume of current fiber(disk)

Return type:

float

static gen_heuristic_fibers(ref_point, fiber_temp, dist_factor, rng)[source]

Move fiber to its reference point

Parameters:
  • ref_point (np.ndarray) – Reference point that the fiber should move to

  • fiber_temp (np.ndarray) – The considering fiber

  • dist_factor (float) – the minimum distance factor between two fibers

  • rng (Any) – random generator

Returns:

The updated location of the considering fiber

Return type:

np.ndarray

generate_microstructure(seed=None)[source]

generate microstructure

Parameters:

seed (Any, optional) – seed number, by default None

Return type:

None

static generate_random_fibers(len_start, len_end, wid_start, wid_end, radius_mu, radius_std, rng)[source]

generate random fibers with different radiis

Parameters:
  • len_start (float) – the start location of length

  • len_end (float) – the end location of length

  • wid_start (float) – the start location of width

  • wid_end (float) – the end location of width

  • radius_mu (float) – mean of radius

  • radius_std (float) – standard deviation of radius

  • rng (any) – random seed or generator

Returns:

location information of generated fiber

Return type:

np.ndarray

static min_dis_index(temp_fiber, fiber_pos, fiber_min_dis_vector, ii, cycle)[source]

This function is used to identify the index of closest fiber of every fiber, which is very import for the first heuristic stirring to get more space placing the new disks.

Parameters:
  • temp_fiber (np.ndarray) – the fiber been processed

  • fiber_pos (np.ndarray) – fiber position

  • fiber_min_dis_vector (np.ndarray) – the first column is the index of the closed point, the second column contains the minimum distance between those two points

  • ii (int) – the index of the being processed point

  • cycle (int) – the cycle of the algorithm. At different cycles, the criteria of identifying the closed point are different.

Return type:

Tuple[ndarray, int, float]

Returns:

  • fiber_min_dis_vector (np.ndarray) – The updated minimum distance array

  • min_index (int) – The index of the minimum distance point

  • min_dist (float) – The minimum distance to the minimum distance point

new_positions(x_center, y_center, radius, width, length)[source]

This is the function used to determine the locations of disks considering the boundary of RVE. To be specific, the disk should be divided into two parts or four parts if it is located in the outskirt area

Parameters:
  • x_center (float) – new center of X axis

  • y_center (float) – new center of Y axis

  • radius (float) – radius of the disk

  • width (float) – width of RVE

  • length (float) – length of RVE

Return type:

ndarray

Returns:

  • np.ndarray – XC, YC, split which is the new locations of this fiber (because in some locations, the circles need to be split)

  • ####################################

  • # # 2_2 # #

  • # 4_1 # #4_2 #

  • ####################################

  • # # # #

  • # 2_3 # 1 # 2_4 #

  • # # # #

  • # # # #

  • ####################################

  • # 4_3 # 2_1 # 4_4 #

  • # # # #

  • ####################################

static overlap_check(new_fiber, fiber_pos, dist_factor, fiber_index=0, stage='step_one')[source]

overlap check between new fiber and the original ones

Parameters:
  • new_fiber (np.ndarray) – new fiber location

  • fiber_pos (np.ndarray) – original fibers

  • dist_factor (float) – distance factor which used to control the minimum distance between to fibers

  • fiber_index (int, optional) – fiber index , by default 0

  • stage (str, optional) – stage of the algorithm, by default “step_one”

Returns:

a flag number (1: overlap, 0: non-overlap)

Return type:

int

plot_microstructure(save_figure=False, fig_name='mircostructure.png', **kwargs)[source]

plot microstructure

Parameters:
  • save_figure (bool, optional) – save figure or not, by default False

  • fig_name (str, optional) – name of figure, by default “mircostructure.png”

Return type:

None

proper_edge_mesh_location(fiber)[source]

identify proper edge location for meshing

Parameters:

fiber (np.ndarray) – temp fiber

Returns:

status of the fiber(0: improper, 1: proper)

Return type:

int

to_abaqus_format(file_name='micro_structure_info.json')[source]

save rve microstructure to abaqus format

Parameters:

file_name (str, optional) – name of saved file, by default “micro_structure_info.json”

Returns:

a dict contains all info of rve microstructure

Return type:

dict

vertices_mesh_loc(fiber)[source]

identify proper vertices location for meshing

Parameters:

fiber (np.ndarray) – temp fiber

Returns:

status of the fiber(0: improper, 1: proper)

Return type:

int

rvesimulator.microstructure.shpere_particles