Cannonball Implicit Duration#
This example demonstrates determining the duration of a phase using a nonlinear solver to satisfy an endpoint condition. As in the multi-phase cannonball problem, we will simultaneously find the optimal design for the cannonball (its radius) and the optimal flight profile (its launch angle). However, here we will use a single phase that terminates at the condition
The cannonball sizing component#
This component computes the area (needed to compute drag) and mass (needed to compute energy) of a cannonball of a given radius and density.
This component sits upstream of the trajectory model and feeds its outputs to the trajectory as parameters.
import numpy as np
from scipy.interpolate import make_interp_spline
import openmdao.api as om
import dymos as dm
from dymos.models.atmosphere.atmos_1976 import USatm1976Data
#############################################
# Component for the design part of the model
#############################################
class CannonballSizeComp(om.ExplicitComponent):
"""
Compute the area and mass of a cannonball with a given radius and density.
Notes
-----
This component is not vectorized with 'num_nodes' as is the usual way
with Dymos, but is instead intended to compute a scalar mass and reference
area from scalar radius and density inputs. This component does not reside
in the ODE but instead its outputs are connected to the trajectory via
input design parameters.
"""
def setup(self):
self.add_input(name='radius', val=1.0, desc='cannonball radius', units='m')
self.add_input(name='dens', val=7870., desc='cannonball density', units='kg/m**3')
self.add_output(name='mass', shape=(1,), desc='cannonball mass', units='kg')
self.add_output(name='S', shape=(1,), desc='aerodynamic reference area', units='m**2')
self.declare_partials(of='mass', wrt='dens')
self.declare_partials(of='mass', wrt='radius')
self.declare_partials(of='S', wrt='radius')
def compute(self, inputs, outputs):
radius = inputs['radius']
dens = inputs['dens']
outputs['mass'] = (4/3.) * dens * np.pi * radius ** 3
outputs['S'] = np.pi * radius ** 2
def compute_partials(self, inputs, partials):
radius = inputs['radius']
dens = inputs['dens']
partials['mass', 'dens'] = (4/3.) * np.pi * radius ** 3
partials['mass', 'radius'] = 4. * dens * np.pi * radius ** 2
partials['S', 'radius'] = 2 * np.pi * radius
The cannonball ODE component#
This component computes the state rates and the kinetic energy of the cannonball.
By calling the declare_coloring
method wrt all inputs and using method 'fd'
, we’re telling OpenMDAO to automatically determine the sparsity pattern of the outputs with respect to the inputs, and to automatically compute those outputs using a finite-difference approximation.
class CannonballODE(om.ExplicitComponent):
"""
Cannonball ODE assuming flat earth and accounting for air resistance
"""
def initialize(self):
self.options.declare('num_nodes', types=int)
def setup(self):
nn = self.options['num_nodes']
# static parameters
self.add_input('m', units='kg')
self.add_input('S', units='m**2')
# 0.5 good assumption for a sphere
self.add_input('CD', 0.5)
# time varying inputs
self.add_input('h', units='m', shape=nn)
self.add_input('v', units='m/s', shape=nn)
self.add_input('gam', units='rad', shape=nn)
# state rates
self.add_output('v_dot', shape=nn, units='m/s**2', tags=['dymos.state_rate_source:v'])
self.add_output('gam_dot', shape=nn, units='rad/s', tags=['dymos.state_rate_source:gam'])
self.add_output('h_dot', shape=nn, units='m/s', tags=['dymos.state_rate_source:h'])
self.add_output('r_dot', shape=nn, units='m/s', tags=['dymos.state_rate_source:r'])
self.add_output('ke', shape=nn, units='J')
# Ask OpenMDAO to compute the partial derivatives using finite-difference
# with a partial coloring algorithm for improved performance, and use
# a graph coloring algorithm to automatically detect the sparsity pattern.
self.declare_coloring(wrt='*', method='fd')
alt_data = USatm1976Data.alt * om.unit_conversion('ft', 'm')[0]
rho_data = USatm1976Data.rho * om.unit_conversion('slug/ft**3', 'kg/m**3')[0]
self.rho_interp = make_interp_spline(np.array(alt_data),
np.array(rho_data),
k=1)
def compute(self, inputs, outputs):
gam = inputs['gam']
v = inputs['v']
h = inputs['h']
m = inputs['m']
S = inputs['S']
CD = inputs['CD']
GRAVITY = 9.80665 # m/s**2
rho = self.rho_interp(h)
q = 0.5*rho*v**2
qS = q * S
D = qS * CD
cgam = np.cos(gam)
sgam = np.sin(gam)
outputs['v_dot'] = - D/m-GRAVITY*sgam
outputs['gam_dot'] = -(GRAVITY/v)*cgam
outputs['h_dot'] = v*sgam
outputs['r_dot'] = v*cgam
outputs['ke'] = 0.5*m*v**2
Generating an initial guess#
Since we will be using a nonlinear solver to converge the dynamics and the duration, a simple linear initial guess will not be sufficient. The initial guess we will use is generated from the kinematics equations that assume no atmospheric drag. We compute the state values for some duration and initial flight path angle
def initial_guess(t_dur, gam0=np.pi/3):
t = np.linspace(0, t_dur, num=100)
g = -9.80665
v0 = -0.5*g*t_dur/np.sin(gam0)
r = v0*np.cos(gam0)*t
h = v0*np.sin(gam0)*t + 0.5*g*t**2
v = np.sqrt(v0*np.cos(gam0)**2 + (v0*np.sin(gam0) + g*t)**2)
gam = np.arctan2(v0*np.sin(gam0) + g*t, v0*np.cos(gam0)**2)
guess = {'t': t, 'r': r, 'h': h, 'v': v, 'gam': gam}
return guess
Building and running the problem#
The following code defines the components for the physical cannonball calculations and ODE problem, sets up trajectory using a single phase, and specifies the stopping condition for the phase. The initial flight path angle is free, since 45 degrees is not necessarily optimal once air resistance is taken into account.
p = om.Problem(name='cannonball_implicit_duration', model=om.Group())
p.driver = om.pyOptSparseDriver()
p.driver.options['optimizer'] = 'IPOPT'
p.driver.declare_coloring()
p.driver.opt_settings['derivative_test'] = 'first-order'
p.driver.opt_settings['mu_strategy'] = 'monotone'
p.driver.opt_settings['alpha_for_y'] = 'safer-min-dual-infeas'
p.driver.opt_settings['bound_mult_init_method'] = 'mu-based'
p.driver.opt_settings['mu_init'] = 0.01
p.driver.opt_settings['nlp_scaling_method'] = 'gradient-based'
p.set_solver_print(level=0, depth=99)
p.model.add_subsystem('size_comp', CannonballSizeComp(),
promotes_inputs=['radius', 'dens'])
p.model.set_input_defaults('dens', val=7.87, units='g/cm**3')
p.model.add_design_var('radius', lower=0.01, upper=0.10,
ref0=0.01, ref=0.10, units='m')
traj = p.model.add_subsystem('traj', dm.Trajectory())
transcription = dm.Radau(num_segments=25, order=3, compressed=False)
phase = dm.Phase(ode_class=CannonballODE, transcription=transcription)
phase = traj.add_phase('phase', phase)
# Duration is bounded to be greater than 1 to ensure the nonlinear solve
# does not converge to the initial point.
phase.set_time_options(fix_initial=True, duration_bounds=(1, 100), units='s')
# All initial states except flight path angle are fixed
# The output of the ODE which provides the rate source for each state
# is obtained from the tags used on those outputs in the ODE.
# The units of the states are automatically inferred by multiplying the units
# of those rates by the time units.
phase.add_state('r', fix_initial=True, solve_segments='forward')
phase.add_state('h', fix_initial=True, lower=0.0, solve_segments='forward')
phase.add_state('gam', fix_initial=False, solve_segments='forward')
phase.add_state('v', fix_initial=False, solve_segments='forward')
phase.add_parameter('S', units='m**2', static_target=True)
phase.add_parameter('m', units='kg', static_target=True)
phase.add_parameter('CD', val=0.5, opt=False, static_target=True)
phase.add_boundary_constraint('ke', loc='initial',
upper=400000, lower=0, ref=100000)
# A duration balance is added setting altitude to zero.
# A nonlinear solver is used to find the duration of required to satisfy the condition.
phase.set_duration_balance('h', val=0.0)
# Prior to setup, this phase has the default NonlinearRunOnce and LinearRunOnce solvers.
# Because of the implicit behavior introduced by set_duration_balance, it will automatically
# use a NewtonSolver with an Armijo Goldstein linesearch.
# In this case that linesearch causes extrapolation of the atmospheric model into invalid regions.
# To account for this, we explicitly assign a NewtonSolver with a different linesearch.
phase.nonlinear_solver = om.NewtonSolver(iprint=0, solve_subsystems=True)
phase.nonlinear_solver.linesearch = None
phase.add_objective('r', loc='final', scaler=-1.0)
p.model.connect('size_comp.mass', 'traj.phase.parameters:m')
p.model.connect('size_comp.S', 'traj.phase.parameters:S')
# Finish Problem Setup
p.setup()
#############################################
# Set constants and initial guesses
#############################################
p.set_val('radius', 0.05, units='m')
p.set_val('dens', 7.87, units='g/cm**3')
p.set_val('traj.phase.parameters:CD', 0.5)
guess = initial_guess(t_dur=30.0)
phase.set_time_val(initial=0.0, duration=30.0)
phase.set_state_val('r', vals=guess['r'], time_vals=guess['t'])
phase.set_state_val('h', vals=guess['h'], time_vals=guess['t'])
phase.set_state_val('v', vals=guess['v'], time_vals=guess['t'])
phase.set_state_val('gam', vals=guess['gam'], time_vals=guess['t'], units='rad')
#####################################################
# Run the optimization and final explicit simulation
#####################################################
dm.run_problem(p, simulate=True, make_plots=True)
/usr/share/miniconda/envs/test/lib/python3.11/site-packages/dymos/transcriptions/transcription_base.py:390: OpenMDAOWarning:'traj.phases.phase' <class Phase>
Non-default solvers are required
implicit duration: True
solved segments: True
input initial: False
Setting `traj.phases.phase.linear_solver = om.DirectSolver(iprint=2)`
Explicitly set traj.phases.phase.linear_solver to override.
Set `traj.phases.phase.options["auto_solvers"] = False` to disable this behavior.
--- Constraint Report [traj] ---
--- phase ---
[initial] 0.0000e+00 <= ke <= 4.0000e+05 [J]
'rhs_checking' is disabled for 'DirectSolver in 'traj.phases.phase' <class Phase>' but that solver has redundant adjoint solves. If it is expensive to compute derivatives for this solver, turning on 'rhs_checking' may improve performance.
Model viewer data has already been recorded for Driver.
Model viewer data has already been recorded for Driver.
Coloring for 'traj.phases.phase.rhs_all' (class CannonballODE)
Jacobian shape: (500, 303) (0.92% nonzero)
FWD solves: 6 REV solves: 0
Total colors vs. total size: 6 vs 303 (98.02% improvement)
Sparsity computed using tolerance: 1e-25
Time to compute sparsity: 0.0616 sec
Time to compute coloring: 0.0302 sec
Memory to compute coloring: 0.5000 MB
Full total jacobian for problem 'cannonball_implicit_duration' was computed 3 times, taking 0.24642708800001856 seconds.
Total jacobian shape: (98, 100)
Jacobian shape: (98, 100) (24.16% nonzero)
FWD solves: 27 REV solves: 0
Total colors vs. total size: 27 vs 100 (73.00% improvement)
Sparsity computed using tolerance: 1e-25
Time to compute sparsity: 0.2464 sec
Time to compute coloring: 0.0799 sec
Memory to compute coloring: 3.4648 MB
Coloring created on: 2024-12-11 19:22:06
Optimization Problem -- Optimization using pyOpt_sparse
================================================================================
Objective Function: _objfunc
Solution:
--------------------------------------------------------------------------------
Total Time: 17.8387
User Objective Time : 15.0098
User Sensitivity Time : 2.5001
Interface Time : 0.1782
Opt Solver Time: 0.1506
Calls to Objective Function : 272
Calls to Sens Function : 64
Objectives
Index Name Value
0 traj.phase.states:r -3.182962E+03
Variables (c - continuous, i - integer, d - discrete)
Index Name Type Lower Bound Value Upper Bound Status
0 radius_0 c 0.000000E+00 3.540935E-01 1.000000E+00
1 traj.phase.t_duration_0 c 1.000000E+00 1.000000E+02 1.000000E+02 u
2 traj.phase.states:r_0 c -1.000000E+21 4.358674E+02 1.000000E+21
3 traj.phase.states:r_1 c -1.000000E+21 7.590748E+02 1.000000E+21
4 traj.phase.states:r_2 c -1.000000E+21 1.017858E+03 1.000000E+21
5 traj.phase.states:r_3 c -1.000000E+21 1.234832E+03 1.000000E+21
6 traj.phase.states:r_4 c -1.000000E+21 1.422454E+03 1.000000E+21
7 traj.phase.states:r_5 c -1.000000E+21 1.588317E+03 1.000000E+21
8 traj.phase.states:r_6 c -1.000000E+21 1.737382E+03 1.000000E+21
9 traj.phase.states:r_7 c -1.000000E+21 1.873055E+03 1.000000E+21
10 traj.phase.states:r_8 c -1.000000E+21 1.997754E+03 1.000000E+21
11 traj.phase.states:r_9 c -1.000000E+21 2.113240E+03 1.000000E+21
12 traj.phase.states:r_10 c -1.000000E+21 2.220814E+03 1.000000E+21
13 traj.phase.states:r_11 c -1.000000E+21 2.321446E+03 1.000000E+21
14 traj.phase.states:r_12 c -1.000000E+21 2.415863E+03 1.000000E+21
15 traj.phase.states:r_13 c -1.000000E+21 2.504610E+03 1.000000E+21
16 traj.phase.states:r_14 c -1.000000E+21 2.588097E+03 1.000000E+21
17 traj.phase.states:r_15 c -1.000000E+21 2.666640E+03 1.000000E+21
18 traj.phase.states:r_16 c -1.000000E+21 2.740483E+03 1.000000E+21
19 traj.phase.states:r_17 c -1.000000E+21 2.809829E+03 1.000000E+21
20 traj.phase.states:r_18 c -1.000000E+21 2.874851E+03 1.000000E+21
21 traj.phase.states:r_19 c -1.000000E+21 2.935708E+03 1.000000E+21
22 traj.phase.states:r_20 c -1.000000E+21 2.992555E+03 1.000000E+21
23 traj.phase.states:r_21 c -1.000000E+21 3.045544E+03 1.000000E+21
24 traj.phase.states:r_22 c -1.000000E+21 3.094834E+03 1.000000E+21
25 traj.phase.states:r_23 c -1.000000E+21 3.140584E+03 1.000000E+21
26 traj.phase.states:h_0 c 0.000000E+00 2.675247E+02 1.000000E+21
27 traj.phase.states:h_1 c 0.000000E+00 4.559863E+02 1.000000E+21
28 traj.phase.states:h_2 c 0.000000E+00 5.966683E+02 1.000000E+21
29 traj.phase.states:h_3 c 0.000000E+00 7.042126E+02 1.000000E+21
30 traj.phase.states:h_4 c 0.000000E+00 7.866603E+02 1.000000E+21
31 traj.phase.states:h_5 c 0.000000E+00 8.488961E+02 1.000000E+21
32 traj.phase.states:h_6 c 0.000000E+00 8.941005E+02 1.000000E+21
33 traj.phase.states:h_7 c 0.000000E+00 9.244540E+02 1.000000E+21
34 traj.phase.states:h_8 c 0.000000E+00 9.415149E+02 1.000000E+21
35 traj.phase.states:h_9 c 0.000000E+00 9.464409E+02 1.000000E+21
36 traj.phase.states:h_10 c 0.000000E+00 9.401267E+02 1.000000E+21
37 traj.phase.states:h_11 c 0.000000E+00 9.232969E+02 1.000000E+21
38 traj.phase.states:h_12 c 0.000000E+00 8.965698E+02 1.000000E+21
39 traj.phase.states:h_13 c 0.000000E+00 8.605030E+02 1.000000E+21
40 traj.phase.states:h_14 c 0.000000E+00 8.156258E+02 1.000000E+21
41 traj.phase.states:h_15 c 0.000000E+00 7.624604E+02 1.000000E+21
42 traj.phase.states:h_16 c 0.000000E+00 7.015338E+02 1.000000E+21
43 traj.phase.states:h_17 c 0.000000E+00 6.333831E+02 1.000000E+21
44 traj.phase.states:h_18 c 0.000000E+00 5.585554E+02 1.000000E+21
45 traj.phase.states:h_19 c 0.000000E+00 4.776043E+02 1.000000E+21
46 traj.phase.states:h_20 c 0.000000E+00 3.910837E+02 1.000000E+21
47 traj.phase.states:h_21 c 0.000000E+00 2.995403E+02 1.000000E+21
48 traj.phase.states:h_22 c 0.000000E+00 2.035071E+02 1.000000E+21
49 traj.phase.states:h_23 c 0.000000E+00 1.034977E+02 1.000000E+21
50 traj.phase.states:gam_0 c -1.000000E+21 5.588421E-01 1.000000E+21
51 traj.phase.states:gam_1 c -1.000000E+21 5.398183E-01 1.000000E+21
52 traj.phase.states:gam_2 c -1.000000E+21 5.135919E-01 1.000000E+21
53 traj.phase.states:gam_3 c -1.000000E+21 4.797861E-01 1.000000E+21
54 traj.phase.states:gam_4 c -1.000000E+21 4.379026E-01 1.000000E+21
55 traj.phase.states:gam_5 c -1.000000E+21 3.873720E-01 1.000000E+21
56 traj.phase.states:gam_6 c -1.000000E+21 3.276273E-01 1.000000E+21
57 traj.phase.states:gam_7 c -1.000000E+21 2.582140E-01 1.000000E+21
58 traj.phase.states:gam_8 c -1.000000E+21 1.789448E-01 1.000000E+21
59 traj.phase.states:gam_9 c -1.000000E+21 9.009122E-02 1.000000E+21
60 traj.phase.states:gam_10 c -1.000000E+21 -7.423246E-03 1.000000E+21
61 traj.phase.states:gam_11 c -1.000000E+21 -1.118972E-01 1.000000E+21
62 traj.phase.states:gam_12 c -1.000000E+21 -2.208807E-01 1.000000E+21
63 traj.phase.states:gam_13 c -1.000000E+21 -3.314122E-01 1.000000E+21
64 traj.phase.states:gam_14 c -1.000000E+21 -4.404250E-01 1.000000E+21
65 traj.phase.states:gam_15 c -1.000000E+21 -5.451911E-01 1.000000E+21
66 traj.phase.states:gam_16 c -1.000000E+21 -6.436482E-01 1.000000E+21
67 traj.phase.states:gam_17 c -1.000000E+21 -7.345245E-01 1.000000E+21
68 traj.phase.states:gam_18 c -1.000000E+21 -8.172792E-01 1.000000E+21
69 traj.phase.states:gam_19 c -1.000000E+21 -8.919362E-01 1.000000E+21
70 traj.phase.states:gam_20 c -1.000000E+21 -9.588927E-01 1.000000E+21
71 traj.phase.states:gam_21 c -1.000000E+21 -1.018753E+00 1.000000E+21
72 traj.phase.states:gam_22 c -1.000000E+21 -1.072207E+00 1.000000E+21
73 traj.phase.states:gam_23 c -1.000000E+21 -1.119950E+00 1.000000E+21
74 traj.phase.states:gam_24 c -1.000000E+21 -1.162642E+00 1.000000E+21
75 traj.phase.states:v_0 c -1.000000E+21 5.750208E+02 1.000000E+21
76 traj.phase.states:v_1 c -1.000000E+21 3.997230E+02 1.000000E+21
77 traj.phase.states:v_2 c -1.000000E+21 3.060111E+02 1.000000E+21
78 traj.phase.states:v_3 c -1.000000E+21 2.471803E+02 1.000000E+21
79 traj.phase.states:v_4 c -1.000000E+21 2.066205E+02 1.000000E+21
80 traj.phase.states:v_5 c -1.000000E+21 1.769413E+02 1.000000E+21
81 traj.phase.states:v_6 c -1.000000E+21 1.543746E+02 1.000000E+21
82 traj.phase.states:v_7 c -1.000000E+21 1.368146E+02 1.000000E+21
83 traj.phase.states:v_8 c -1.000000E+21 1.230084E+02 1.000000E+21
84 traj.phase.states:v_9 c -1.000000E+21 1.121737E+02 1.000000E+21
85 traj.phase.states:v_10 c -1.000000E+21 1.037991E+02 1.000000E+21
86 traj.phase.states:v_11 c -1.000000E+21 9.752644E+01 1.000000E+21
87 traj.phase.states:v_12 c -1.000000E+21 9.307777E+01 1.000000E+21
88 traj.phase.states:v_13 c -1.000000E+21 9.020962E+01 1.000000E+21
89 traj.phase.states:v_14 c -1.000000E+21 8.868761E+01 1.000000E+21
90 traj.phase.states:v_15 c -1.000000E+21 8.827832E+01 1.000000E+21
91 traj.phase.states:v_16 c -1.000000E+21 8.875202E+01 1.000000E+21
92 traj.phase.states:v_17 c -1.000000E+21 8.989107E+01 1.000000E+21
93 traj.phase.states:v_18 c -1.000000E+21 9.149864E+01 1.000000E+21
94 traj.phase.states:v_19 c -1.000000E+21 9.340453E+01 1.000000E+21
95 traj.phase.states:v_20 c -1.000000E+21 9.546733E+01 1.000000E+21
96 traj.phase.states:v_21 c -1.000000E+21 9.757521E+01 1.000000E+21
97 traj.phase.states:v_22 c -1.000000E+21 9.964290E+01 1.000000E+21
98 traj.phase.states:v_23 c -1.000000E+21 1.016074E+02 1.000000E+21
99 traj.phase.states:v_24 c -1.000000E+21 1.034254E+02 1.000000E+21
Constraints (i - inequality, e - equality)
Index Name Type Lower Value Upper Status Lagrange Multiplier (N/A)
0 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -8.526513E-13 0.000000E+00 9.00000E+100
1 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -7.958079E-13 0.000000E+00 9.00000E+100
2 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -6.821210E-13 0.000000E+00 9.00000E+100
3 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -9.094947E-13 0.000000E+00 9.00000E+100
4 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -4.547474E-13 0.000000E+00 9.00000E+100
5 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
6 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -1.136868E-12 0.000000E+00 9.00000E+100
7 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -2.273737E-13 0.000000E+00 9.00000E+100
8 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -4.547474E-13 0.000000E+00 9.00000E+100
9 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
10 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 4.547474E-13 0.000000E+00 9.00000E+100
11 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
12 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 4.547474E-13 0.000000E+00 9.00000E+100
13 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -4.547474E-13 0.000000E+00 9.00000E+100
14 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
15 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -4.547474E-13 0.000000E+00 9.00000E+100
16 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
17 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -9.094947E-13 0.000000E+00 9.00000E+100
18 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 4.547474E-13 0.000000E+00 9.00000E+100
19 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
20 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 9.094947E-13 0.000000E+00 9.00000E+100
21 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 9.094947E-13 0.000000E+00 9.00000E+100
22 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 4.547474E-13 0.000000E+00 9.00000E+100
23 traj.phase.continuity_comp.defect_states:r e 0.000000E+00 -9.094947E-13 0.000000E+00 9.00000E+100
24 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -5.684342E-13 0.000000E+00 9.00000E+100
25 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -3.979039E-13 0.000000E+00 9.00000E+100
26 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -4.547474E-13 0.000000E+00 9.00000E+100
27 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -4.547474E-13 0.000000E+00 9.00000E+100
28 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -2.273737E-13 0.000000E+00 9.00000E+100
29 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -2.273737E-13 0.000000E+00 9.00000E+100
30 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -2.273737E-13 0.000000E+00 9.00000E+100
31 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 2.273737E-13 0.000000E+00 9.00000E+100
32 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 1.136868E-13 0.000000E+00 9.00000E+100
33 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -3.410605E-13 0.000000E+00 9.00000E+100
34 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
35 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 2.273737E-13 0.000000E+00 9.00000E+100
36 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 1.136868E-13 0.000000E+00 9.00000E+100
37 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
38 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
39 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
40 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 3.410605E-13 0.000000E+00 9.00000E+100
41 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 1.136868E-13 0.000000E+00 9.00000E+100
42 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -2.273737E-13 0.000000E+00 9.00000E+100
43 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -2.273737E-13 0.000000E+00 9.00000E+100
44 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -1.136868E-13 0.000000E+00 9.00000E+100
45 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -5.684342E-14 0.000000E+00 9.00000E+100
46 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -1.136868E-13 0.000000E+00 9.00000E+100
47 traj.phase.continuity_comp.defect_states:h e 0.000000E+00 -5.684342E-14 0.000000E+00 9.00000E+100
48 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 1.110223E-16 0.000000E+00 9.00000E+100
49 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 4.440892E-16 0.000000E+00 9.00000E+100
50 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 1.110223E-16 0.000000E+00 9.00000E+100
51 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 3.330669E-16 0.000000E+00 9.00000E+100
52 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 3.330669E-16 0.000000E+00 9.00000E+100
53 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 2.220446E-16 0.000000E+00 9.00000E+100
54 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 7.216450E-16 0.000000E+00 9.00000E+100
55 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 1.942890E-16 0.000000E+00 9.00000E+100
56 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 1.526557E-16 0.000000E+00 9.00000E+100
57 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 3.903128E-16 0.000000E+00 9.00000E+100
58 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 1.942890E-16 0.000000E+00 9.00000E+100
59 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 1.665335E-16 0.000000E+00 9.00000E+100
60 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 2.220446E-16 0.000000E+00 9.00000E+100
61 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 -5.551115E-17 0.000000E+00 9.00000E+100
62 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
63 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 1.110223E-16 0.000000E+00 9.00000E+100
64 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 -3.330669E-16 0.000000E+00 9.00000E+100
65 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 2.220446E-16 0.000000E+00 9.00000E+100
66 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 1.110223E-16 0.000000E+00 9.00000E+100
67 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 1.110223E-16 0.000000E+00 9.00000E+100
68 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 2.220446E-16 0.000000E+00 9.00000E+100
69 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 -2.220446E-16 0.000000E+00 9.00000E+100
70 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 0.000000E+00 0.000000E+00 9.00000E+100
71 traj.phase.continuity_comp.defect_states:gam e 0.000000E+00 -4.440892E-16 0.000000E+00 9.00000E+100
72 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 1.762146E-12 0.000000E+00 9.00000E+100
73 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 9.663381E-13 0.000000E+00 9.00000E+100
74 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 6.252776E-13 0.000000E+00 9.00000E+100
75 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 4.547474E-13 0.000000E+00 9.00000E+100
76 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 3.694822E-13 0.000000E+00 9.00000E+100
77 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 2.557954E-13 0.000000E+00 9.00000E+100
78 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 1.989520E-13 0.000000E+00 9.00000E+100
79 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 1.989520E-13 0.000000E+00 9.00000E+100
80 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 1.278977E-13 0.000000E+00 9.00000E+100
81 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 9.947598E-14 0.000000E+00 9.00000E+100
82 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 9.947598E-14 0.000000E+00 9.00000E+100
83 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 9.947598E-14 0.000000E+00 9.00000E+100
84 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 7.105427E-14 0.000000E+00 9.00000E+100
85 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 5.684342E-14 0.000000E+00 9.00000E+100
86 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 9.947598E-14 0.000000E+00 9.00000E+100
87 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 8.526513E-14 0.000000E+00 9.00000E+100
88 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 5.684342E-14 0.000000E+00 9.00000E+100
89 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 5.684342E-14 0.000000E+00 9.00000E+100
90 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 7.105427E-14 0.000000E+00 9.00000E+100
91 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 1.136868E-13 0.000000E+00 9.00000E+100
92 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 9.947598E-14 0.000000E+00 9.00000E+100
93 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 8.526513E-14 0.000000E+00 9.00000E+100
94 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 1.136868E-13 0.000000E+00 9.00000E+100
95 traj.phase.continuity_comp.defect_states:v e 0.000000E+00 1.278977E-13 0.000000E+00 9.00000E+100
96 traj.phases.phase->initial_boundary_constraint->ke i 0.000000E+00 4.000000E+00 4.000000E+00 u 9.00000E+100
Exit Status
Inform Description
0 Solve Succeeded
--------------------------------------------------------------------------------
Simulating trajectory traj
Model viewer data has already been recorded for Driver.
Done simulating trajectory traj
Problem: cannonball_implicit_duration
Driver: pyOptSparseDriver
success : True
iterations : 273
runtime : 1.8453E+01 s
model_evals : 273
model_time : 1.4937E+01 s
deriv_evals : 64
deriv_time : 2.2248E+00 s
exit_status : SUCCESS
Displaying the timeseries data#
from IPython.display import HTML
# Define the path to the HTML file
html_file_path = p.get_reports_dir() / 'traj_results_report.html'
html_content = html_file_path.read_text()
# Inject CSS to control the output cell height and avoid scrollbars
html_with_custom_height = f"""
<div style="height: 800px; overflow: auto;">
{html_content}
</div>
"""
HTML(html_with_custom_height)