Tutorial: Lightweight optimisation using a gradient-based lamination parameter approach#

Date: 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 a buckling constraint multiplied by a target load factor. The design variables are continuous: the thickness \(h\) and the lamination parameters \(\xi_{D1}\) and \(\xi_{D3}\) of a balanced and symmetric laminate, which give the bending stiffnesses through the material invariants. The steps are: define the bending stiffnesses from the lamination parameters, the buckling load and its analytical gradient, verify the buckling load against the first row of Table 3 of Le Riche and Haftka, and run the gradient-based optimiser SLSQP of SciPy, with finite-difference and with analytical gradients of the constraint.

Required modules#

The tutorial uses numpy, scipy, composites, installed e.g. with

python -m pip install numpy scipy 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

Laminate plate geometry and applied loading:#

image.png

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).

\[\frac{\lambda_b(m, n)}{\pi^2} = \frac{\left[D_{11} (m/a)^4 + 2 (D_{12} + 2 D_{66}) (m/a)^2 (n/b)^2 + D_{22} (n/b)^4\right]}{((m/a)^2 Nxx + (n/b)^2 Nyy)}\ (1)\]

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.

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\):

image-1.png

These 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)\), does not follow from the strain transformation, which gives \(\gamma_{12}^i = 2\sin\theta_i\cos\theta_i(\epsilon_y - \epsilon_x) = \sin 2\theta_i(\epsilon_y - \epsilon_x)\) for \(\gamma_{xy} = 0\); the printed \(\sin^2\theta_i\) is most likely a misprint of \(\sin 2\theta_i\). The tutorial opt-lightweight-smeared-finite-diff-Le-Riche gives the references and uses the corrected expression. This tutorial has only the buckling constraint.

[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:

image-2.png

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.

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 load factor of the first row of Table 3 is reproduced to a relative difference of 7.5e-7 (checked below); with the rounded SI values 127.55, 13.03 and 6.41 GPa the difference is 4.2e-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]:
import numpy as np

# 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))
# 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]:
def get_Q_matrix(theta_deg):
    """
    Calculate the transformed reduced stiffness matrix Q_bar for a given angle.
    """
    nu21 = nu12 * E22 / E11
    denom = 1 - nu12 * nu21
    Q11 = E11 / denom
    Q22 = E22 / denom
    Q12 = nu12 * E22 / denom
    Q66 = G12

    c = np.cos(np.radians(theta_deg))
    s = np.sin(np.radians(theta_deg))

    c2 = c**2; s2 = s**2; c4 = c**4; s4 = s**4

    Q_bar_11 = Q11*c4 + 2*(Q12 + 2*Q66)*s2*c2 + Q22*s4
    Q_bar_22 = Q11*s4 + 2*(Q12 + 2*Q66)*s2*c2 + Q22*c4
    Q_bar_12 = (Q11 + Q22 - 4*Q66)*s2*c2 + Q12*(s4 + c4)
    Q_bar_66 = (Q11 + Q22 - 2*Q12 - 2*Q66)*s2*c2 + Q66*(s4 + c4)

    Q_bar_44 = G23 * c2 + G13 * s2
    Q_bar_55 = G13 * c2 + G23 * s2
    Q_bar_45 = (G13 - G23) * c * s

    Q_bar = np.array([
        [Q_bar_11, Q_bar_12, 0, 0, 0, 0],
        [Q_bar_12, Q_bar_22, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0],
        [0, 0, 0, Q_bar_44, Q_bar_45, 0],
        [0, 0, 0, Q_bar_45, Q_bar_55, 0],
        [0, 0, 0, 0, 0, Q_bar_66]
    ])
    return Q_bar
[4]:
class LaminationParameterProp:
    def __init__(self, h, xiD1, xiD3):
        # Pre-calculate Base Q matrices
        self.Q0 = get_Q_matrix(0)
        Q11 = self.Q0[0,0]
        Q22 = self.Q0[1,1]
        Q12 = self.Q0[0,1]
        Q66 = self.Q0[5,5]

        self.xiD1 = xiD1
        self.xiD2 = None
        self.xiD3 = xiD3
        self.xiD4 = None
        self.U1 = (3*Q11 + 3*Q22 + 2*Q12 + 4*Q66)/8
        self.U2 = (Q11 - Q22)/2
        self.U3 = (Q11 + Q22 - 2*Q12 - 4*Q66)/8
        self.U4 = (Q11 + Q22 + 6*Q12 - 4*Q66)/8
        self.U5 = (Q11 + Q22 - 2*Q12 + 4*Q66)/8

        self.h = h

        self.D11 = h**3/12*(self.U1 + xiD1*self.U2 + xiD3*self.U3)
        self.D22 = h**3/12*(self.U1 - xiD1*self.U2 + xiD3*self.U3)
        self.D12 = h**3/12*(-xiD3*self.U3 + self.U4)
        self.D66 = h**3/12*(-xiD3*self.U3 + self.U5)

Analytical equation to calculate buckling#

[5]:
from numpy import pi

def calc_buckling_analytical(prop):
    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 = prop.D11
    D12 = prop.D12
    D22 = prop.D22
    D66 = prop.D66
    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

Analytical buckling gradients#

[6]:
def calc_buckling_analytical_jac(prop):
    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 = prop.D11
    D12 = prop.D12
    D22 = prop.D22
    D66 = prop.D66

    lambda_b_min = 1e30
    lambda_b_h = None
    lambda_b_xiD1 = None
    lambda_b_xiD3 = None

    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)
                       )
            lambdas = [lambda_b_min, lambda_b]
            argmin = np.argmin(lambdas)
            lambda_b_min = lambdas[argmin]

            den = (m/a)**2*Nxx + (n/b)**2*Nyy
            lambda_b_D11 = pi**2*(m/a)**4/den
            lambda_b_D12 = 2*pi**2*(m/a)**2*(n/b)**2/den
            lambda_b_D22 = pi**2*(n/b)**4/den
            lambda_b_D66 = 4*pi**2*(m/a)**2*(n/b)**2/den

            # Derivatives of D11
            D11_h = 3 * prop.h**2 / 12 * (prop.U1 + prop.xiD1 * prop.U2 + prop.xiD3 * prop.U3)
            D11_xiD1 = prop.h**3 / 12 * prop.U2
            #D11_xiD2 = 0
            D11_xiD3 = prop.h**3 / 12 * prop.U3
            #D11_xiD4 = 0

            # Derivatives of D22
            D22_h = 3 * prop.h**2 / 12 * (prop.U1 - prop.xiD1 * prop.U2 + prop.xiD3 * prop.U3)
            D22_xiD1 = -prop.h**3 / 12 * prop.U2
            #D22_xiD2 = 0
            D22_xiD3 = prop.h**3 / 12 * prop.U3
            #D22_xiD4 = 0

            # Derivatives of D12
            D12_h = 3 * prop.h**2 / 12 * (-prop.xiD3 * prop.U3 + prop.U4)
            D12_xiD1 = 0
            #D12_xiD2 = 0
            D12_xiD3 = -prop.h**3 / 12 * prop.U3
            #D12_xiD4 = 0

            # Derivatives of D66
            D66_h = 3 * prop.h**2 / 12 * (-prop.xiD3 * prop.U3 + prop.U5)
            D66_xiD1 = 0
            D66_xiD2 = 0
            D66_xiD3 = -prop.h**3 / 12 * prop.U3
            D66_xiD4 = 0

            lambda_b_h_new = (lambda_b_D11 * D11_h
                                + lambda_b_D12 * D12_h
                                + lambda_b_D22 * D22_h
                                + lambda_b_D66 * D66_h)

            lambda_b_xiD1_new = (lambda_b_D11 * D11_xiD1
                                    + lambda_b_D22 * D22_xiD1
                                    + lambda_b_D12 * D12_xiD1
                                    + lambda_b_D66 * D66_xiD1)

            lambda_b_xiD3_new = (lambda_b_D11 * D11_xiD3
                                    + lambda_b_D22 * D22_xiD3
                                    + lambda_b_D12 * D12_xiD3
                                    + lambda_b_D66 * D66_xiD3)

            lambda_b_h = [lambda_b_h, lambda_b_h_new][argmin]
            lambda_b_xiD1 = [lambda_b_xiD1, lambda_b_xiD1_new][argmin]
            lambda_b_xiD3 = [lambda_b_xiD3, lambda_b_xiD3_new][argmin]

    lambda_b_x = [lambda_b_h, lambda_b_xiD1, lambda_b_xiD3]

    return lambda_b_x

Verifying constraint functions#

Compare with column 2 of Table 3 (p. 955) below, first row.

d816f009-00df-4e4b-88dd-db58c2d1bbe5.png

[7]:
from composites import laminated_plate

h = ply_thickness*len(stack_ref)
lam = laminated_plate(plyt=ply_thickness, stack=stack_ref, laminaprop=laminaprop)
lp = lam.calc_lamination_parameters()
prop_ref = LaminationParameterProp(*[h, lp.xiD1, lp.xiD3])

lambda_cb_ref_analytical = calc_buckling_analytical(prop_ref)
print('lambda_cb_ref_analytical', lambda_cb_ref_analytical)
print()
print('%-38s %14s %14s %10s' % ('first row of Table 3', 'this notebook',
                                 'Le Riche 1993', 'rel. diff.'))
value, ref = lambda_cb_ref_analytical, 14168.12
print('%-38s %14.2f %14.2f %10.1e' % ('buckling load factor', value, ref,
                                      abs(value - ref)/ref))
lambda_cb_ref_analytical 14168.130594010214

first row of Table 3                    this notebook  Le Riche 1993 rel. diff.
buckling load factor                         14168.13       14168.12    7.5e-07

Verifying the analytical gradient#

The gradient of the buckling load factor with respect to \(h\), \(\xi_{D1}\) and \(\xi_{D3}\), used by the optimiser, is compared with central finite differences at the reference design.

[8]:
x_check = np.array([h, lp.xiD1, lp.xiD3])
grad = np.asarray(calc_buckling_analytical_jac(LaminationParameterProp(*x_check)))
print('%-12s %16s %16s %10s' % ('variable', 'analytical',
                                 'finite diff.', 'rel. diff.'))
for i, name in enumerate(('h', 'xiD1', 'xiD3')):
    dx = 1e-6*max(abs(x_check[i]), 1e-3)
    xp, xm = x_check.copy(), x_check.copy()
    xp[i] += dx
    xm[i] -= dx
    fd = (calc_buckling_analytical(LaminationParameterProp(*xp))
          - calc_buckling_analytical(LaminationParameterProp(*xm)))/(2*dx)
    print('%-12s % 16.6e % 16.6e %10.1e' % (name, grad[i], fd,
                                            abs(grad[i] - fd)/abs(fd)))
variable           analytical     finite diff. rel. diff.
h                6.972505e+06     6.972505e+06    4.0e-11
xiD1             0.000000e+00     0.000000e+00        nan
xiD3            -3.176403e+03    -3.176403e+03    2.2e-10
/home/saullogiovanip/align2026/runs/w8SCn-20261106-223112/tmp/ipykernel_63660/1289179676.py:13: RuntimeWarning: invalid value encountered in scalar divide
  abs(grad[i] - fd)/abs(fd)))

Defining design load#

[9]:
target_lambda = 10000

Defining objective function#

[10]:
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
    h = x[0]
    return rho*h*a*b # [m^3]

Defining constraint functions#

[11]:
def calc_constr_buckling(x): # NOTE feasible when >= 0
    prop = LaminationParameterProp(*x)
    lambda_b = calc_buckling_analytical(prop)
    return lambda_b/target_lambda - 1

def calc_constr_buckling_jac(x):
    prop = LaminationParameterProp(*x)
    lambda_b_x = calc_buckling_analytical_jac(prop)
    return np.asarray(lambda_b_x)/target_lambda

Optimisation using SLSQP#

Here we define the optimization problem:

[12]:
from scipy.optimize import minimize
from scipy.optimize import Bounds

n_var = 3
h_min = ply_thickness
h_max = 48*ply_thickness
x0 = [(h_min + h_max) / 2.0, 0, 0]
rel_step = 1e-8 # relative finite-difference step, see the next section
bounds = Bounds([h_min, -1, -1], [h_max, +1, +1])

# NOTE inequality constraints: fun(x) >= 0

for use_gradient in [False, True]:

    if use_gradient:
        constraints = [{'type': 'ineq', 'fun': calc_constr_buckling, 'jac': calc_constr_buckling_jac},
                       ]
    else:
        constraints = [{'type': 'ineq', 'fun': calc_constr_buckling},
                       ]
    print()
    print("Starting SLSQP Optimization with Scipy, gradient=%s" % str(use_gradient))
    print()

    options = {'ftol': 1e-9, 'disp': True, 'maxiter': 200}
    if not use_gradient:
        # NOTE finite-difference step relative to each design variable
        options['finite_diff_rel_step'] = rel_step

    res = minimize(
        mass,
        x0,
        method='SLSQP',
        bounds=bounds,
        constraints=constraints,
        options=options,
        jac="2-point"
    )

    print("    Best solution found: %s" % res.x)

    print("    Checking best solution")
    prop_opt = LaminationParameterProp(*res.x)
    ms_buckling_opt = calc_buckling_analytical(prop_opt)/target_lambda - 1
    print('    mass', mass(res.x))
    print('    ms_buckling_opt', ms_buckling_opt)

    lambda_cb_opt_analytical = calc_buckling_analytical(prop_opt)
    print('    lambda_cb_opt_analytical', lambda_cb_opt_analytical)

Starting SLSQP Optimization with Scipy, gradient=False

Optimization terminated successfully    (Exit mode 0)
            Current function value: 0.5310387395334248
            Iterations: 22
            Function evaluations: 125
            Gradient evaluations: 19
    Best solution found: [ 0.00514445 -0.35677661 -1.        ]
    Checking best solution
    mass 0.5310387395334248
    ms_buckling_opt 2.886579864025407e-14
    lambda_cb_opt_analytical 10000.00000000029

Starting SLSQP Optimization with Scipy, gradient=True

Optimization terminated successfully    (Exit mode 0)
            Current function value: 0.5310387395334536
            Iterations: 25
            Function evaluations: 111
            Gradient evaluations: 25
    Best solution found: [ 0.00514445 -0.2446189  -1.        ]
    Checking best solution
    mass 0.5310387395334536
    ms_buckling_opt 4.5075054799781356e-14
    lambda_cb_opt_analytical 10000.000000000451

Finite-difference step#

Without an analytical Jacobian of the constraint, SLSQP approximates it by forward differences, as the gradient of the objective (jac="2-point"). SciPy’s default absolute step is \(\sqrt{\epsilon}\,\max(1, |x_i|) \approx 1.49 \times 10^{-8}\,\max(1, |x_i|)\), with \(\epsilon\) the machine precision, which assumes design variables of order one. The lamination parameters are of order one, but the thickness \(h\), in metres, lies between \(1.27 \times 10^{-4}\) and \(6.10 \times 10^{-3}\) m: at the starting point, \(h = 3.11 \times 10^{-3}\) m, its step, \(1.49 \times 10^{-8}\) m, is \(4.8 \times 10^{-6}\,h\), about 300 times larger relative to the variable than that of the lamination parameters. Since \(\lambda_b \propto h^3\), the forward difference overestimates \(\partial \lambda_b / \partial h\) by about the step divided by \(h\) (checked below at the starting point: \(4.8 \times 10^{-6}\) relative error). With the option finite_diff_rel_step the step is relative to each variable, \(r\,|x_i|\); here \(r = 10^{-8}\), of the size of SciPy’s default for variables of order one, which reduces the error of \(\partial \lambda_b / \partial h\) to \(3 \times 10^{-8}\).

[13]:
from scipy.optimize._numdiff import approx_derivative

x_start = np.array(x0)
grad = calc_constr_buckling_jac(x_start)
print('%-26s %14s %14s %14s' % ('step', 'd/dh', 'd/dxiD1', 'd/dxiD3'))
print('%-26s % 14.6e % 14.6e % 14.6e' % ('analytical', *grad))
for label, r in (('default', None), ('finite_diff_rel_step=1e-8', 1e-8)):
    fd = approx_derivative(calc_constr_buckling, x_start, method='2-point',
                           rel_step=r, bounds=(bounds.lb, bounds.ub))
    print('%-26s % 14.6e % 14.6e % 14.6e' % (label, *fd))
    print('%-26s % 14.1e % 14.1e % 14.1e' % ('  rel. diff.',
                                            *(abs(fd - grad)/abs(grad))))
step                                 d/dh        d/dxiD1        d/dxiD3
analytical                   1.723868e+02  -5.040381e-02  -3.557137e-02
default                      1.723876e+02  -5.040380e-02  -3.557137e-02
  rel. diff.                      4.8e-06        1.4e-07        1.4e-07
finite_diff_rel_step=1e-8    1.723868e+02  -5.040380e-02  -3.557137e-02
  rel. diff.                      3.2e-08        1.4e-07        1.4e-07

Results#

Both runs start from the same point. With the analytical gradient of the buckling constraint SLSQP converges to a mass of 0.5310 kg, with the buckling constraint active and \(\xi_{D3}\) at its lower bound \(-1\). With finite-difference gradients and the relative step \(r = 10^{-8}\) it reaches the same mass and thickness (table below), with \(\xi_{D3} = -1\) and a different \(\xi_{D1}\); the runs of the table that reach the optimum end with different values of \(\xi_{D1}\) at the same mass.

The path of SLSQP is sensitive to small changes of the gradients in this problem, whose design variables have very different scales (\(h\) in metres against \(\xi_{D1}, \xi_{D3} \in [-1, 1]\)). Both runs first reach \(h\) at its upper bound, 48 ply thicknesses, with \(\xi_{D1} = \xi_{D3} = -1\). From there the run with the analytical gradient reduces \(h\), while the run with SciPy’s default step keeps \(h\) at the bound and only changes \(\xi_{D1}\), until the buckling constraint is satisfied after three iterations, at 0.6293 kg, the thickness of the reference laminate: a feasible design, but not the minimum. Its gradient error is small (\(10^{-3}\) of 479 in \(\partial (\lambda_b/\lambda_{target})/\partial h\) at that point), and the end point does not change monotonically with the step: the study below repeats the run for several relative steps. Steps of \(10^{-8}\) and \(10^{-7}\) reach the optimum; the default and relative steps of \(10^{-9}\) and \(10^{-6}\) stop at the upper bound of \(h\) (outputs stored with SciPy 1.16.0; the end points of this study may differ with another SciPy version). The smeared tutorials use design variables of order one instead, the thicknesses in numbers of plies.

[14]:
mass_analytical = None
rows = []
for label, cjac, r in (('analytical gradient', calc_constr_buckling_jac, None),
                       ('default step', None, None),
                       ('finite_diff_rel_step=1e-9', None, 1e-9),
                       ('finite_diff_rel_step=1e-8', None, 1e-8),
                       ('finite_diff_rel_step=1e-7', None, 1e-7),
                       ('finite_diff_rel_step=1e-6', None, 1e-6)):
    constraint = {'type': 'ineq', 'fun': calc_constr_buckling}
    options = {'ftol': 1e-9, 'disp': False, 'maxiter': 200}
    if cjac is not None:
        constraint['jac'] = cjac
    if r is not None:
        options['finite_diff_rel_step'] = r
    res = minimize(mass, x0, method='SLSQP', bounds=bounds,
                   constraints=[constraint], options=options, jac="2-point")
    if mass_analytical is None:
        mass_analytical = res.fun
    rows.append((label, res.status, res.nit, res.x[0]/ply_thickness,
                 res.x[1], res.x[2], res.fun,
                 (res.fun - mass_analytical)/mass_analytical))

print('%-26s %9s %10s %8s %8s %8s %10s %10s' % ('constraint gradient',
      'exit mode', 'iterations', 'h/t', 'xiD1', 'xiD3', 'mass [kg]', 'rel. diff.'))
for row in rows:
    print('%-26s %9d %10d %8.3f %8.4f %8.4f %10.6f %10.1e' % row)
constraint gradient        exit mode iterations      h/t     xiD1     xiD3  mass [kg] rel. diff.
analytical gradient                0         25   40.507  -0.2446  -1.0000   0.531039    0.0e+00
default step                       0          3   48.000  -0.7916  -1.0000   0.629263    1.8e-01
finite_diff_rel_step=1e-9          0          3   48.000  -0.7916  -1.0000   0.629263    1.8e-01
finite_diff_rel_step=1e-8          0         22   40.507  -0.3568  -1.0000   0.531039   -5.4e-14
finite_diff_rel_step=1e-7          0         25   40.507  -0.3433  -1.0000   0.531039    3.2e-11
finite_diff_rel_step=1e-6          0          3   48.000  -0.7916  -1.0000   0.629263    1.8e-01
[ ]: