Tutorial: discrete-based lightweight optimisation using the ghost layer method#
Date: 31 August 2024
Last update: 4 February 2026
Author: Saullo G. P. Castro
Cite this tutorial as:
Castro, SGP. Methods for analysis and design of composites [Computer software]. https://doi.org/10.5281/zenodo.2871782
This tutorial minimises the mass of a simply supported rectangular laminated plate under biaxial compression, the design problem of Le Riche and Haftka (1993), with two constraints: the buckling load and the strain allowables of the plies, both multiplied by a target load factor. The design variables are integers: half of them choose the angle of each ply among 0, 45 and 90 degrees, the other half whether the ply exists, the ghost layer approach, such that the optimiser can also remove plies.
The steps are: define the constraint functions, verify them against the first row of Table 3 of Le Riche and Haftka, and run a genetic algorithm of pymoo.
Required modules#
The tutorial uses numpy, scipy, pymoo, composites, installed e.g. with
python -m pip install numpy scipy pymoo composites
References#
Le Riche, R. and Haftka, R. T., Optimization of Laminate Stacking Sequence for Buckling Load Maximization by Genetic Algorithm, AIAA Journal, 31(5), 951-956, 1993. https://doi.org/10.2514/3.11710
Le Riche, R., Optimization of Composite Structures by Genetic Algorithms, PhD dissertation, Virginia Polytechnic Institute and State University, Blacksburg, VA, 1994. http://hdl.handle.net/10919/38270
Kassapoglou, C., Design and Analysis of Composite Structures: With Applications to Aerospace Structures, 2nd ed., Wiley, 2013. https://doi.org/10.1002/9781118536933
Barbero, E. J., Introduction to Composite Materials Design, 3rd ed., CRC Press, 2017. https://doi.org/10.1201/9781315296494
Castro, S. G. P., and Guimar, T. A. M., 2010, “Comparison of Free Stacking Sequence Approach versus a Predefined 0 / + 45 / -45 / 90 Sequence in a Typical Aircraft Wing Optimization,” 2nd International Conference on Engineering Optimization (ENGOPT), Lisbon, Portugal, pp. 1–11. https://www.researchgate.net/publication/233406751_Comparison_of_free_stacking_sequence_approach_versus_a_predefined_045-4590_sequence_in_a_typical_aircraft_wing_optimization
Schläpfer, B., and Kress, G., 2012, “A Sensitivity-Based Parameterization Concept for the Automated Design and Placement of Reinforcement Doublers,” Compos. Struct., 94(3), pp. 896–903. https://linkinghub.elsevier.com/retrieve/pii/S0263822311003655
Ghost layer, or free stacking sequence, or “T-THETA”, …
based on the same principle of creating dummy layers that can removed or added during the optimization
Main idea behind the ghost layer method:#
duplicate the number of design variables to be able to add or remove layers
Laminate plate geometry and applied loading:#
Fig. 1 of Le Riche and Haftka (1993), p. 951.
Constraint - Critical buckling load \(\lambda_b\), calculated analytically with:#
Le Riche and Haftka (1993), Eq. (1), p. 952. The paper prints the middle term of the numerator as \(2(D_{12} + 2D_{66})(m/a)^2\), without the factor \((n/b)^2\), a misprint: every term of the numerator must have the dimension of \(D_{11}(m/a)^4\). The equation below has the factor; with it the buckling load factor of the first row of Table 3 is reproduced (checked below).
Constraint - strain failure#
This constraint requires that all strain components remain below an allowable limit, assuming that \(\gamma_{xy}\) will be zero for this bi-axial loading, given that the laminate is balanced. Le Riche and Haftka (1993, p. 952) state that \(\gamma_{xy}\) is zero in their case. The ultimate allowable strains of the paper (p. 952) are \(\epsilon_1^{ua} = 0.008\), \(\epsilon_2^{ua} = 0.029\) and \(\gamma_{12}^{ua} = 0.015\), with a safety factor of 1.5, which the failure function below applies to the loads.
The principal strains on each layer can be calculated solving first the laminate bi-axial strains \(\epsilon_x\) and \(\epsilon_y\); and later the in-plane strains of each layer: \(\epsilon_1^i\), \(\epsilon_2^i\) and \(\gamma_{12}^i\):
The equations above are Eqs. (2) and (3) of Le Riche and Haftka (1993), p. 952. The shear strain printed there, \(\gamma_{12}^i = \sin^2\theta_i(\epsilon_y - \epsilon_x)\), which Le Riche (1994, Chapter 4, p. 58) repeats, does not follow from the strain transformation: at \(\theta_i = 90°\) the ply axes are the laminate axes and \(\gamma_{12}^i = \gamma_{xy} = 0\). This notebook uses the transformation of the engineering strains (Le Riche 1994, Appendix B, Eq. (B.15), p. 174; Kassapoglou 2013, Eq. (3.36), p. 44; Barbero 2017, Eqs. (5.39) and (5.40), p. 163):
that is \(\sin 2\theta_i(\epsilon_y - \epsilon_x)\): the printed \(\sin^2\theta_i\) is most likely a misprint of \(\sin 2\theta_i\).
The expression of the paper gives half of this value in the \(\pm 45\) plies. In a laminate with both \(\pm 45\) and 90 degree plies the largest \(|\gamma_{12}^i|\) is \(|\epsilon_y - \epsilon_x|\) with both expressions, so the failure load factor of Table 3 is the same; without 90 degree plies the paper’s expression overestimates the shear failure load factor by a factor of 2.
[1]:
# NOTE ultimate allowable strains, Le Riche and Haftka (1993), p. 952
epsilon_1_allowable = 0.008
epsilon_2_allowable = 0.029
gamma_12_allowable = 0.015
Optimization description#
Take as reference the first design case of Table 3 of Le Riche and Haftka (1993), p. 955:
Strain failure is the critical failure mode of all the laminates of Table 3 (p. 955): their failure load factor is below their buckling load factor.
Note that the number of plies here has been pre-defined to 48 plies, and with the ghost layer approach, we will be able to remove plies.
We will set a target design load by means of a target lambda that will multiply the bi-axial loading state.
Defining the reference case#
Using the first stacking sequence of the Table 3 above.
The first row of Table 3 (p. 955) is the laminate \((90_2, \pm 45_4, 0_4, \pm 45, 0_4, \pm 45, 0_2)_s\) of 48 plies, with \(a = 20\) in, \(b = 5\) in, \(N_x = 1\) and \(N_y = 0.125\). The footnote of Table 3 gives the loads in lb, Fig. 8 (p. 956) in lb/in; they are loads per unit length, in lb/in here. The material data of the paper (p. 952) are \(E_1 = 18.50 \times 10^6\) psi, \(E_2 = 1.89 \times 10^6\) psi, \(G_{12} = 0.93 \times 10^6\) psi, \(\nu_{12} = 0.3\) and the ply thickness \(t = 0.005\) in. They are converted below exactly, with 1 psi = 1 lbf/in\(^2\) = 4.4482216152605 N/(0.0254 m)\(^2\) = 6894.757 Pa (the pound-force and the inch are defined exactly in SI units): \(E_1 = 127.553\) GPa, \(E_2 = 13.031\) GPa and \(G_{12} = 6.412\) GPa. The paper gives the rounded SI values 127.59, 13.03 and 6.41 GPa; its 127.59 GPa is a conversion slip, since \(18.50 \times 10^6\) psi is 127.55 GPa. With the exact conversions the buckling and failure load factors of the first row of Table 3 are reproduced to relative differences of 7.5e-7 and 4.6e-8 (checked below); with the rounded SI values 127.55, 13.03 and 6.41 GPa the differences are 4.2e-5 and 5.1e-5. The paper gives no density and no transverse shear moduli: \(\rho = 1600\) kg/m\(^3\) is chosen here, and \(G_{13}\) and \(G_{23}\), set equal to \(G_{12}\), do not enter \(A\) and \(D\).
[2]:
# Table 03, first row
a_value = 20. # [in]
b_value = 5. # [in]
load_Nxx_unit = 1. # [lb/in]
load_Nyy_unit = 0.125 # [lb/in]
stack_ref_half = [90]*2 + [+45,-45]*4 + [0]*4 + [+45, -45] + [0]*4 + [+45, -45] + [0]*2
stack_ref = stack_ref_half + stack_ref_half[::-1] # symmetry condition
print('number of plies:', len(stack_ref))
num_variables = len(stack_ref) // 4 # NOTE independent angles for a symmetric and balanced laminate
# NOTE: make sure that you understand this
num_variables = 2*num_variables # NOTE twice as many variables needed for the ghost layer approach
# material properties, Le Riche and Haftka (1993), p. 952, converted from psi
psi = 4.4482216152605/0.0254**2 # [Pa], 1 lbf/in^2
E11 = 18.50e6*psi # [Pa]
E22 = 1.89e6*psi
nu12 = 0.3
G12 = 0.93e6*psi
G13 = G12 # NOTE not given in the paper, does not enter A and D
G23 = G12
rho = 1600 # kg/m^3
laminaprop = (E11, E22, nu12, G12, G13, G23)
ply_thickness = 0.005*25.4/1000 # [m]
h = ply_thickness*len(stack_ref)
number of plies: 48
[3]:
from composites import laminated_plate
lam_ref = laminated_plate(stack=stack_ref, plyt=ply_thickness, laminaprop=laminaprop)
Analytical equation to calculate buckling#
[4]:
from numpy import pi
def calc_buckling_analytical(lam):
a = a_value*25.4/1000 # [m] along x
b = b_value*25.4/1000 # [m] along y
Nxx = load_Nxx_unit*4.448222/(25.4/1000) #[N/m]
Nyy = load_Nyy_unit*4.448222/(25.4/1000) #[N/m]
D11 = lam.ABD[3, 3]
D12 = lam.ABD[3, 4]
D22 = lam.ABD[4, 4]
D66 = lam.ABD[5, 5]
lambda_b_min = 1e30
for m in range(1, 21):
for n in range(1, 21):
lambda_b = (pi**2*(D11*(m/a)**4
+ 2*(D12 + 2*D66)*(m/a)**2*(n/b)**2
+ D22*(n/b)**4)/((m/a)**2*Nxx + (n/b)**2*Nyy)
)
lambda_b_min = min(lambda_b_min, lambda_b)
return lambda_b_min
Function to calculate strain failure criterion#
[5]:
import numpy as np
import scipy.optimize as opt
def calc_failure_load_Haftka(lam):
def strain_MS(lbd):
Nxx = -load_Nxx_unit*4.448222/(25.4/1000) #[N/m]
Nyy = -load_Nyy_unit*4.448222/(25.4/1000) #[N/m]
Nxx = lbd*Nxx*1.5
Nyy = lbd*Nyy*1.5
vecN = np.asarray([Nxx, Nyy])
A11 = lam.ABD[0, 0]
A12 = lam.ABD[0, 1]
A22 = lam.ABD[1, 1]
exx, eyy = np.linalg.inv(np.array([[A11, A12], [A12, A22]])) @ vecN
margin_of_safety = 1e15
for thetadeg in lam.stack:
cost = np.cos(np.deg2rad(thetadeg))
sint = np.sin(np.deg2rad(thetadeg))
epsilon_i_1 = cost**2*exx + sint**2*eyy
epsilon_i_2 = sint**2*exx + cost**2*eyy
gamma_i_12 = 2*sint*cost*(eyy - exx) # NOTE gamma_xy = 0
ms_new = min(
epsilon_1_allowable/abs(epsilon_i_1) - 1,
epsilon_2_allowable/abs(epsilon_i_2) - 1,
gamma_12_allowable/abs(gamma_i_12) - 1
)
margin_of_safety = min(margin_of_safety, ms_new)
return margin_of_safety
lbd_init = 100
positiveMS = opt.NonlinearConstraint(strain_MS, 0., np.inf, jac='2-point')
res = opt.minimize(strain_MS, lbd_init, tol=1e-6, bounds=((100, None),),
constraints=[positiveMS], jac='2-point')
if not res.success:
raise RuntimeError(res.message)
return res.x[0]
Verifying constraint functions#
Compare with columns 2 and 3 of Table 3 (p. 955) below, first row.
[6]:
lambda_cb_ref_analytical = calc_buckling_analytical(lam_ref)
print('lambda_cb_ref_analytical', lambda_cb_ref_analytical)
lambda_cs_ref = calc_failure_load_Haftka(lam_ref)
print('lambda_cs_ref', lambda_cs_ref)
print()
print('%-38s %14s %14s %10s' % ('first row of Table 3', 'this notebook',
'Le Riche 1993', 'rel. diff.'))
for name, value, ref in (('buckling load factor', lambda_cb_ref_analytical,
14168.12),
('failure load factor', lambda_cs_ref, 13518.66)):
print('%-38s %14.2f %14.2f %10.1e' % (name, value, ref,
abs(value - ref)/ref))
lambda_cb_ref_analytical 14168.130594010201
lambda_cs_ref 13518.659375437172
first row of Table 3 this notebook Le Riche 1993 rel. diff.
buckling load factor 14168.13 14168.12 7.5e-07
failure load factor 13518.66 13518.66 4.6e-08
/home/saullogiovanip/align2026/runs/w7LR-20261106-091218/tmp/ipykernel_99239/2935206276.py:25: RuntimeWarning: divide by zero encountered in divide
gamma_12_allowable/abs(gamma_i_12) - 1
Defining design load#
[7]:
target_lambda = 10000
Stacking sequence and thickness from integer vector#
Half of the \(x\) vector constains information about the layup, the other half about the corresponding ply thickness, implementing the ghost layer approach.
[8]:
available_angles = [0, 45, 90]
ply_thickness = 0.005*25.4/1000 # [m]
def layup_thick_from_x(x):
layup = []
plyts = []
for xi in x[0:len(x)//2]:
layup.append(available_angles[xi])
for xi in x[len(x)//2:]:
plyts.append(ply_thickness*xi)
layup_bal = []
plyts_bal = []
for angle_deg, plyt in zip(layup, plyts): # balancing
layup_bal.append(angle_deg)
plyts_bal.append(plyt)
if angle_deg != 0 and angle_deg != 90:
layup_bal.append(-angle_deg)
plyts_bal.append(plyt)
else:
layup_bal.append(angle_deg)
plyts_bal.append(plyt)
layup_bal = layup_bal + layup_bal[::-1] # symmetry
plyts_bal = plyts_bal + plyts_bal[::-1] # symmetry
non_zero = np.logical_not(np.asarray(plyts_bal) == 0)
return np.asarray(layup_bal)[non_zero], np.asarray(plyts_bal)[non_zero]
Defining objective function#
[9]:
#def objective_Workshop1(x): # NOTE to be minimized
# stack = discrete_stack_from_continuous_x(x)
# lam = laminated_plate(stack=stack, plyt=ply_thickness, laminaprop=laminaprop)
# lambda_cb = calc_buckling_FE(lam)
# lambda_cs = calc_failure_load_Haftka(lam)
# p = 0.08 # NOTE Le Riche and Haftka (1993), p. 955
# obj = (1 - p)*min(lambda_cs, lambda_cb)
# return 1/obj
def mass(x): # NOTE to be minimized
a = a_value*25.4/1000 # [m] along x
b = b_value*25.4/1000 # [m] along y
stack, thicknesses = layup_thick_from_x(x)
return rho*sum(thicknesses)*a*b # [m^3]
Defining constraint functions#
[10]:
def calc_constr_buckling(x): # NOTE feasible when <= 0
stack, thicknesses = layup_thick_from_x(x)
lam = laminated_plate(stack=stack, plyts=thicknesses, laminaprop=laminaprop)
lambda_cb = calc_buckling_analytical(lam)
return 1 - lambda_cb/target_lambda
def calc_constr_failure(x): # NOTE feasible when <= 0
stack, thicknesses = layup_thick_from_x(x)
lam = laminated_plate(stack=stack, plyts=thicknesses, laminaprop=laminaprop)
lambda_cs = calc_failure_load_Haftka(lam)
return 1 - lambda_cs/target_lambda
test = [2, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
stack, thicknesses = layup_thick_from_x(test)
print(stack.tolist())
print(stack_ref_half)
print(len(stack))
lam = laminated_plate(stack=stack, plyts=thicknesses, laminaprop=laminaprop)
lambda_cb = calc_buckling_analytical(lam)
print(lambda_cb)
[90, 90, 45, -45, 45, -45, 45, -45, 45, -45, 0, 0, 0, 0, 45, -45, 0, 0, 0, 0, 45, -45, 0, 0, 0, 0, -45, 45, 0, 0, 0, 0, -45, 45, 0, 0, 0, 0, -45, 45, -45, 45, -45, 45, -45, 45, 90, 90]
[90, 90, 45, -45, 45, -45, 45, -45, 45, -45, 0, 0, 0, 0, 45, -45, 0, 0, 0, 0, 45, -45, 0, 0]
48
14168.130594010201
Global optimization using pymoo#
Based on the tutorials:
https://pymoo.org/problems/definition.html
https://pymoo.org/customization/discrete.html?highlight=integerrandomsampling
https://www.pymoo.org/constraints/index.html
Here we define the optimization problem:
[11]:
from pymoo.core.problem import ElementwiseProblem
from pymoo.optimize import minimize
from pymoo.algorithms.soo.nonconvex.ga import GA
from pymoo.operators.sampling.rnd import IntegerRandomSampling
from pymoo.operators.crossover.sbx import SBX
from pymoo.operators.mutation.pm import PM
from pymoo.operators.repair.rounding import RoundingRepair
n_plies = 48
n_var = 2*(n_plies//4)
# define permutation problem
class Problem(ElementwiseProblem):
def __init__(self):
super().__init__(n_var = n_var,
n_obj = 1,
xl = [0]*n_var, # NOTE variables always changing from 0 to xu
xu = [len(available_angles)-1]*(n_var//2) + [1]*(n_var//2),
n_ieq_constr = 2,
vtype = int)
def _evaluate(self, x, out, *args, **kwargs):
x = np.asarray(x, dtype=int)
layup, plyts = layup_thick_from_x(x)
out['F'] = mass(x) # objective function
out['G'] = [calc_constr_buckling(x), calc_constr_failure(x)]
problem = Problem()
Defining the optimization method, here using a genetic algorithm:
[12]:
method = algorithm = GA(
pop_size=20,
sampling=IntegerRandomSampling(),
crossover=SBX(prob=0.9, eta=3.0, vtype=float, repair=RoundingRepair()),
mutation=PM(prob=0.05, eta=3.0, vtype=float, repair=RoundingRepair()),
eliminate_duplicates=True)
Running the optimization:
[13]:
res = minimize(problem,
method,
termination=('n_gen', 40),
seed=1,
save_history=True
)
print("Best solution found: %s" % res.X)
print("Function value: %s" % res.F)
print("Constraint violation: %s" % res.CV)
/home/saullogiovanip/align2026/runs/w7LR-20261106-091218/tmp/ipykernel_99239/2935206276.py:25: RuntimeWarning: divide by zero encountered in divide
gamma_12_allowable/abs(gamma_i_12) - 1
Best solution found: [2 1 2 1 1 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 1 1 1]
Function value: [0.57682465]
Constraint violation: [0.]
Checking the optimization result:
[14]:
stack_opt, thicknesses_opt = layup_thick_from_x(res.X)
lam_opt = laminated_plate(stack=stack_opt, plyts=thicknesses_opt, laminaprop=laminaprop)
ms_buckling_opt = calc_buckling_analytical(lam_opt)/target_lambda - 1
ms_failure_opt = calc_failure_load_Haftka(lam_opt)/target_lambda - 1
print('num of layers', len(stack_opt))
print('mass', mass(res.X))
print('ms_buckling_opt', ms_buckling_opt)
print('ms_failure_opt', ms_failure_opt)
print('optimal layup', stack_opt)
lambda_cb_opt_analytical = calc_buckling_analytical(lam_opt)
print('lambda_cb_opt_analytical', lambda_cb_opt_analytical)
lambda_cs_opt = calc_failure_load_Haftka(lam_opt)
print('lambda_cs_opt', lambda_cs_opt)
num of layers 44
mass 0.5768246528000004
ms_buckling_opt 0.0032980710809675795
ms_failure_opt 0.28536768377227073
optimal layup [ 90 90 45 -45 90 90 45 -45 45 -45 0 0 0 0 0 0 0 0
45 -45 0 0 0 0 -45 45 0 0 0 0 0 0 0 0 -45 45
-45 45 90 90 -45 45 90 90]
lambda_cb_opt_analytical 10032.980710809676
lambda_cs_opt 12853.676837722707
/home/saullogiovanip/align2026/runs/w7LR-20261106-091218/tmp/ipykernel_99239/2935206276.py:25: RuntimeWarning: divide by zero encountered in divide
gamma_12_allowable/abs(gamma_i_12) - 1
[ ]: