SEC.ColumnElements#

SEC.ColumnElements.py

class SolidGrain(id_, center, radius, poreradius, poredist)#

Bases: object

A class to represent a solid grain with pores.

id_#

The identifier of the grain.

Type:

any

center#

The (x, y) coordinates of the grain center.

Type:

array-like

radius#

The radius of the grain.

Type:

float

poreradius#

The radius of the pores in the grain.

Type:

float

poredist#

The distance between the centers of adjacent pores.

Type:

float

entries#

An array of tuples representing the angular ranges of the pores.

Type:

np.ndarray

Initialize a SolidGrain instance.

Parameters:
  • id (any) – The identifier of the grain.

  • center (array-like) – The (x, y) coordinates of the grain center.

  • radius (float) – The radius of the grain.

  • poreradius (float) – The radius of the pores in the grain.

  • poredist (float) – The distance between the centers of adjacent pores.

compute_poreentries()#

Compute the angular ranges of the pores in the grain.

draw_entries(ax)#

Draw the pore entries on the given axes.

Parameters:

ax (matplotlib.axes.Axes) – The axes on which to draw the pore entries.

draw(ax, color=None, alpha=1)#

Draw the grain on the given axes.

Parameters:
  • ax (matplotlib.axes.Axes) – The axes on which to draw the grain.

  • color (str, optional) – The color of the grain. If None, a default color will be used.

  • alpha (float, optional) – The transparency of the grain. Default is 1 (opaque).

get_point_from_angle(angle)#

Get a point on the grain surface corresponding to the given angle.

Parameters:

angle (float) – The angle in radians.

Returns:

point – The (x, y) coordinates of the point on the grain surface.

Return type:

np.ndarray

get_entry_including(angles, debug=False)#

Get the index of the pore entry that includes the given angular range.

Parameters:
  • angles (array-like) – A tuple or list of two angles (in radians) defining the angular range.

  • debug (bool, optional) – If True, enables debug mode with additional output.

Returns:

The index of the pore entry that includes the angular range, or None if no such entry exists.

Return type:

int or None

compute_bounce_vector(particle)#

Compute the bounce vector for a particle colliding with the grain.

compute_inpore_nextpos(particle)#

Compute the next position of a particle inside a pore.

class Particle(center, radius)#

Bases: object

A class to represent a particle.

center#

The (x, y) coordinates of the particle center.

Type:

array-like

radius#

The radius of the particle.

Type:

float

Initialize a Particle instance.

Parameters:
  • center (array-like) – The (x, y) coordinates of the particle center.

  • radius (float) – The radius of the particle.

draw(ax, color=None, alpha=1)#

Draw the particle on the given axes.

Parameters:
  • ax (matplotlib.axes.Axes) – The axes on which to draw the particle.

  • color (str, optional) – The color of the particle. If None, a default color will be used.

  • alpha (float, optional) – The transparency of the particle. Default is 1 (opaque).

enters_stationary(grain, last_particle=None, return_point_info=False, ax=None, debug=False)#

Determine if the particle enters a stationary grain.

Parameters:
  • grain (SolidGrain) – The grain to check for entry.

  • last_particle (Particle, optional) – The last particle in the trajectory, used for edge cases.

  • return_point_info (bool, optional) – If True, return detailed point information.

  • ax (matplotlib.axes.Axes, optional) – The axes for drawing debug information.

  • debug (bool, optional) – If True, enables debug mode with additional output.

Returns:

If the particle enters the grain, returns a tuple containing: - angles: list of two angles where the particle enters the grain. - points: list of two points where the particle intersects the grain surface. - entry_index: index of the pore entry that the particle enters. If the particle does not enter, returns None.

Return type:

tuple or None

stationary_move(grain, last_px, last_py, px, py, debug=False)#

Compute the next position of the particle while moving inside a stationary grain.

Parameters:
  • grain (SolidGrain) – The grain in which the particle is moving.

  • last_px (float) – The last x-coordinate of the particle.

  • last_py (float) – The last y-coordinate of the particle.

  • px (float) – The current x-coordinate of the particle.

  • py (float) – The current y-coordinate of the particle.

  • debug (bool, optional) – If True, enables debug mode with additional output.

Returns:

A tuple containing the next (x, y) coordinates of the particle and the state.

Return type:

tuple

class NewGrain(id_, center, radius, num_pores)#

Bases: SolidGrain

A class to represent a grain with multiple pores.

id_#

The identifier of the grain.

Type:

any

center#

The (x, y) coordinates of the grain center.

Type:

array-like

radius#

The radius of the grain.

Type:

float

num_pores#

The number of pores in the grain.

Type:

int

poreradius#

The radius of the pores in the grain.

Type:

float

entries#

An array of tuples representing the angular ranges of the pores.

Type:

np.ndarray

Initialize a NewGrain instance.

Parameters:
  • id (any) – The identifier of the grain.

  • center (array-like) – The (x, y) coordinates of the grain center.

  • radius (float) – The radius of the grain.

  • num_pores (int) – The number of pores in the grain.

compute_poreentries()#

Compute the angular ranges of the pores in the grain.

draw(ax)#

Draw the grain on the given axes. :param ax: The axes on which to draw the grain. :type ax: matplotlib.axes.Axes

new_grain_unit_test()#

Unit test for the NewGrain class.

grain_particle_test()#

Unit test for the SolidGrain and Particle classes.

draw_wedges(ax, center, radius, rad_pairs, colors)#

Draw wedges on the given axes. :param ax: The axes on which to draw the wedges. :type ax: matplotlib.axes.Axes :param center: The (x, y) coordinates of the center of the wedges. :type center: array-like :param radius: The radius of the wedges. :type radius: float :param rad_pairs: A list of tuples, each containing two angles (in radians) defining the angular range of a wedge. :type rad_pairs: list of tuples :param colors: A list of colors for the wedges. :type colors: list of str