def test_ex_brachistochrone_vs_radau_compressed(self): ex_brachistochrone_vs.SHOW_PLOTS = False p = ex_brachistochrone_vs.brachistochrone_min_time(transcription='radau-ps', compressed=True, force_alloc_complex=True, solve_segments=True) p.final_setup() # set the final optimized control profile from # TestBrachistochroneVectorStatesExample.test_ex_brachistochrone_vs_radau_compressed # and see if we get the right state history theta = np.array([2.54206362, 4.8278643, 10.11278149, 12.30024503, 17.35332815, 23.53948016, 25.30747573, 29.39010464, 35.47854735, 37.51549822, 42.16351471, 48.32419264, 50.21299389, 54.56658635, 60.77733663, 62.79222351, 67.35945157, 73.419141, 75.27851226, 79.60246558, 85.89170743, 87.96027845, 92.66164608, 98.89108826, ]) p['phase0.controls:theta'] = theta.reshape((-1, 1)) p['phase0.states:v'][:] = 100. # bad initial guess on purpose p['phase0.states:v'][0] = 0. # have to set the initial condition p['phase0.states:pos'][:] = 100. p['phase0.states:pos'][0, 0] = 0. # have to set the initial condition p['phase0.states:pos'][0, 1] = 10. # have to set the initial condition p['phase0.t_duration'] = 1.8016 # need the final duration (ivp style) p.run_model() self.assert_results(p) # self.assert_partials(p) self.tearDown() if os.path.exists('ex_brachvs_radau_compressed.db'): os.remove('ex_brachvs_radau_compressed.db')
def test_ex_brachistochrone_vs_gl_compressed(self): ex_brachistochrone_vs.SHOW_PLOTS = False p = ex_brachistochrone_vs.brachistochrone_min_time( transcription='gauss-lobatto', compressed=True, force_alloc_complex=True, solve_segments=True) theta = np.array([ 1.04466973, 6.40253991, 12.26063396, 18.51810659, 25.07411252, 31.59842762, 37.76082779, 43.8810928, 50.27900244, 56.67270776, 62.78035981, 68.93138259, 75.45520008, 81.95935786, 88.05140149, 94.03879494, 100.22900215 ]) p['phase0.controls:theta'] = theta.reshape((-1, 1)) p['phase0.states:v'][:] = 100 # bad initial guess on purpose p['phase0.states:v'][0] = 0 # have to set the initial condition p['phase0.states:pos'][:] = 100 p['phase0.states:pos'][0, 0] = 0 # have to set the initial condition p['phase0.states:pos'][0, 1] = 10. # have to set the initial condition p['phase0.t_duration'] = 1.8016 # need the final duration (ivp style) p.run_model() self.assert_results(p) self.tearDown() if os.path.exists('ex_brachvs_gl_compressed.db'): os.remove('ex_brachvs_gl_compressed.db')
def test_ex_brachistochrone_vs_rungekutta_compressed(self): p = ex_brachistochrone_vs.brachistochrone_min_time(transcription='runge-kutta', transcription_order='RK4', compressed=True, force_alloc_complex=True, run_driver=True) self.assert_results(p)
def test_ex_brachistochrone_vs_radau_uncompressed(self): ex_brachistochrone_vs.SHOW_PLOTS = True p = ex_brachistochrone_vs.brachistochrone_min_time(transcription='radau-ps', compressed=False, force_alloc_complex=True, run_driver=True) self.assert_results(p) self.assert_partials(p)
def test_ex_brachistochrone_vs_gl_uncompressed(self): ex_brachistochrone_vs.SHOW_PLOTS = True p = ex_brachistochrone_vs.brachistochrone_min_time(transcription='gauss-lobatto', transcription_order=5, compressed=False, force_alloc_complex=True, run_driver=True) self.assert_results(p) self.assert_partials(p)
def test_ex_brachistochrone_vs_gl_single_segment(self): ex_brachistochrone_vs.SHOW_PLOTS = False p = ex_brachistochrone_vs.brachistochrone_min_time(transcription='gauss-lobatto', compressed=False, force_alloc_complex=True, solve_segments='forward', num_segments=1, transcription_order=11) self.assert_results(p)
def test_ex_brachistochrone_vs_radau_uncompressed(self): ex_brachistochrone_vs.SHOW_PLOTS = False p = ex_brachistochrone_vs.brachistochrone_min_time(transcription='radau-ps', compressed=False, force_alloc_complex=True, solve_segments='forward', num_segments=10, transcription_order=3) self.assert_results(p)
def test_ex_brachistochrone_vs_radau_uncompressed(self): ex_brachistochrone_vs.SHOW_PLOTS = True p = ex_brachistochrone_vs.brachistochrone_min_time(transcription='radau-ps', compressed=False, force_alloc_complex=True, run_driver=True) self.assert_results(p) self.assert_partials(p) self.tearDown() if os.path.exists('ex_brachvs_radau_uncompressed.db'): os.remove('ex_brachvs_radau_uncompressed.db')
def test_ex_brachistochrone_vs_gl_compressed(self): ex_brachistochrone_vs.SHOW_PLOTS = True p = ex_brachistochrone_vs.brachistochrone_min_time( transcription='gauss-lobatto', compressed=True, sim_record='ex_brachvs_gl_compressed.db', force_alloc_complex=True, run_driver=True) self.assert_results(p) self.assert_partials(p) self.tearDown() if os.path.exists('ex_brachvs_gl_compressed.db'): os.remove('ex_brachvs_gl_compressed.db')