Commit b39317b1 authored by Baptiste Durand's avatar Baptiste Durand

Moving to the file kagome.py the effective radius calculation and the round corner method

parent 47b9f11a
......@@ -13,7 +13,7 @@ and instantiate them in a gmsh model.
from .curves import Line, Arc
from .point import Point
from . import factory, np, logger, model
from .tools import round_corner, offset, calcul_R, unit_vect, bisector, angle_between
from .tools import round_corner, offset
from .curves import Line, AbstractCurve
......@@ -205,59 +205,6 @@ class LineLoop(object):
)
self.sides = round_corner_2_sides(result_1D)
def round_corner_kagome(self, r, a, alpha):
""" Opération d'arrondi des angles spécifique à la microstructure 'kagome',
appliquée à tous les sommets du polygone.
alpha = paramètre d'ouverture du kagomé
a :
b : taille des éléments triangulaires
theta : rotation du triangle à l'intérieur de la cellule de base
Parameters
----------
r: float
Rayon du cercle inscrit dans la jonction
a: float
taille de la cellule de base
alpha: float
paramètre d'ouverture de la microstructure
"""
effect_R, phi_1, phi_2 = calcul_R(alpha, r, a)
# ! ESSAI
result_1D = list()
for i in range(len(self.vertices)):
d2 = effect_R / np.sin(phi_2)
d1 = effect_R / np.sin(phi_1)
dir_1 = self.vertices[i - 2].coord - self.vertices[i - 1].coord
dir_2 = self.vertices[i].coord - self.vertices[i - 1].coord
dir_1 = unit_vect(dir_1)
dir_2 = unit_vect(dir_2)
A = Point(self.vertices[i - 1].coord + effect_R * dir_1)
C = Point(self.vertices[i - 1].coord + effect_R * dir_2)
alpha = angle_between(dir_1, dir_2, orient=True)
v_biss = bisector(dir_1, dir_2) if alpha >= 0 else - bisector(dir_1, dir_2)
if abs(abs(angle_between(v_biss, dir_1)) - (np.pi / 2 - phi_2)) < 10e-14:
# si on est du côté où l'angle vaut theta
d = d2
elif abs(abs(angle_between(v_biss, dir_1)) - (np.pi / 2 - phi_1)) < 10e-14:
d = d1
else:
raise ValueError("mauvaise gestion de d1 et d2")
B = Point(self.vertices[i - 1].coord + d * v_biss)
round_arc = Arc(A, B, C)
racc_amt = Line(self.vertices[i - 2], A)
racc_avl = Line(C, self.vertices[i])
curves_list = [racc_amt, round_arc, racc_avl]
result_1D.append(curves_list)
self.sides = round_corner_2_sides(result_1D)
def vertices_2_sides(self):
""" Méthode permettant de générer les segments reliant les sommets.
Si une opération round_corner est utilisé, cette opération est inutile."""
......
......@@ -174,26 +174,6 @@ def round_corner(inp_pt, pt_amt, pt_avl, r, junction_raduis=False, plot=False):
return geoList
def calcul_R(alpha,r,a):
#méthode de construction des jonctions propres au kagomé
x_a = (1 - alpha) * a / 2 - alpha * a
y_a = (1 - alpha) * a * np.sqrt(3) / 2
b = np.sqrt(x_a ** 2 + y_a ** 2)
theta = np.arcsin(np.sqrt(3) * alpha * a / (2 * b))
# Cas kagomé "fermé"
phi_2 = np.pi / 2 - theta
if alpha < 1 / 3:
phi_1 = np.pi / 6 - theta
effect_R = 2 * r * np.sin(phi_1) * np.sin(phi_2) / (
np.sin(phi_2) * np.cos(phi_1) - np.sin(phi_1) * np.cos(phi_2) - np.sin(phi_2) + np.sin(
phi_1))
if alpha >= 1 / 3:
phi_1 = theta - np.pi / 6
effect_R = 2 * r * np.sin(phi_1) * np.sin(phi_2) / (
- np.sin(phi_2) * np.cos(phi_1) - np.sin(phi_1) * np.cos(phi_2) + np.sin(phi_2) + np.sin(phi_1))
return effect_R,phi_1,phi_2
def fine_point_jonction(inp_pt, pt_amt, pt_avl, r,sharp_r):
"""
......
......@@ -352,7 +352,7 @@ class Gmsh2DPart(object):
from .pantograph import pantograph_RVE, pantograph_offset_RVE, beam_pantograph_RVE
from .kagome import kagome_RVE, kagome_sym_RVE
from .kagome import kagome_RVE
# from .other_2d_microstructures import auxetic_square_RVE
......@@ -510,7 +510,6 @@ from . import pantograph
__all__ = [
"pantograph_RVE",
"kagome_RVE",
"kagome_sym_RVE",
"pantograph_offset_RVE",
"beam_pantograph_RVE",
"pantograph_E11only_RVE",
......
......@@ -10,7 +10,7 @@ import logging
import ho_homog.geometry as geo
import gmsh
import ho_homog.mesh_tools as msh
from math import sin, cos, pi
from . import Gmsh2DRVE, logger
......@@ -90,8 +90,7 @@ def kagome_RVE(alpha, r, a=None, b=None, nb_cells=(1, 1), offset=(0.0, 0.0), nam
pattern_ll = geo.remove_duplicates(pattern_ll)
logger.info("Removing duplicate pattern line-loops: Done")
logger.info(f"Number of pattern line-loops: {len(pattern_ll)}")
for ll in pattern_ll:
ll.round_corner_kagome(r * b, a, alpha)
pattern_ll = [round_corner_kagome(ll, r * b, a, alpha) for ll in pattern_ll]
logger.info("Rounding all corners of pattern line-loops: Done")
fine_pts = [pt for ll in pattern_ll for pt in ll.vertices]
fine_pts = geo.remove_duplicates(fine_pts)
......@@ -99,7 +98,6 @@ def kagome_RVE(alpha, r, a=None, b=None, nb_cells=(1, 1), offset=(0.0, 0.0), nam
return Gmsh2DRVE(pattern_ll, gen_vect, nb_cells, offset, fine_pts, False, name,)
def kagome_triangle_size_2_cell_size(alpha, b):
"""Passage de b (côté des triangles) à a (taille caractéristique cellule unitaire du kagome)."""
_a = 1.0 # pour cellule de hauteur 1
......@@ -127,3 +125,94 @@ def kagome_cell_size_2_triangle_size(alpha, a):
t2 = (1 - alpha) * np.sqrt(3) * a / 2
b = np.sqrt(t1 ** 2 + t2 ** 2)
return b
def round_corner_kagome(lineloop, r, a, alpha):
""" Opération d'arrondi des angles spécifique à la microstructure 'kagome',
appliquée à tous les sommets du polygone.
Parameters
----------
lineloop : LineLoop
Contour à modifier
r: float
Rayon du cercle inscrit dans la jonction
a: float
taille de la cellule de base
alpha: float
paramètre d'ouverture de la microstructure
"""
effect_r, phi_1, phi_2 = calcul_effective_r(alpha, r, a)
vertices = lineloop.vertices
# ! ESSAI
results_1d = list()
for i in range(len(vertices)):
cur_pt = vertices[i - 1]
d2 = effect_r / np.sin(phi_2)
d1 = effect_r / np.sin(phi_1)
dir_1 = vertices[i - 2].coord - cur_pt.coord
dir_2 = vertices[i].coord - cur_pt.coord
dir_1 = geo.unit_vect(dir_1)
dir_2 = geo.unit_vect(dir_2)
pt_amt = geo.translation(cur_pt, effect_r * dir_1)
pt_avl = geo.translation(cur_pt, effect_r * dir_2)
alpha = geo.angle_between(dir_1, dir_2, orient=True)
v_biss = geo.bisector(dir_1, dir_2)
if alpha < 0:
v_biss = -v_biss
if abs(abs(geo.angle_between(v_biss, dir_1)) - (np.pi / 2 - phi_2)) < 10e-14:
# si on est du côté où l'angle vaut theta
d = d2
elif abs(abs(geo.angle_between(v_biss, dir_1)) - (np.pi / 2 - phi_1)) < 10e-14:
d = d1
else:
raise ValueError("mauvaise gestion de d1 et d2")
center = geo.translation(cur_pt, d * v_biss)
round_arc = geo.Arc(pt_amt, center, pt_avl)
racc_amt = geo.Line(vertices[i - 2], pt_amt)
racc_avl = geo.Line(pt_avl, vertices[i])
curves_list = [racc_amt, round_arc, racc_avl]
results_1d.append(curves_list)
lineloop.sides = geo.surfaces.round_corner_2_sides(results_1d)
return lineloop
def calcul_effective_r(alpha, r, a):
"""
Méthode de construction des jonctions propre au kagomé.
Parameters
----------
alpha: float
paramètre d'ouverture
r: float
rayon des jonctions
a: float
taille caractéristique de la cellule unitaire
Returns
-------
tuple
3 floats: Effective radius, phi_1, phi_2
"""
b = kagome_cell_size_2_triangle_size(alpha, a)
theta = np.arcsin(np.sqrt(3) * alpha * a / (2 * b))
phi_2 = np.pi / 2 - theta
if alpha < 1 / 3:
phi_1 = np.pi / 6 - theta
effect_r = (2 * r * sin(phi_1) * sin(phi_2)) / (
sin(phi_2) * cos(phi_1) - sin(phi_1) * cos(phi_2) - sin(phi_2) + sin(phi_1)
)
else:
phi_1 = theta - pi / 6
effect_r = (2 * r * sin(phi_1) * sin(phi_2)) / (
-sin(phi_2) * cos(phi_1) - sin(phi_1) * cos(phi_2) + sin(phi_2) + sin(phi_1)
)
return effect_r, phi_1, phi_2
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment