Skip to content

Commit

Permalink
made grid_data available right after instantiaton; address issue #246 (
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinSGray authored and robfalck committed Oct 25, 2019
1 parent 11fe4ba commit 9aa819e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 16 deletions.
2 changes: 0 additions & 2 deletions dymos/phase/phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,6 @@ def setup(self):

transcription = self.options['transcription']

transcription.setup_grid(self)

transcription.setup_time(self)

# The control interpolation comp to which we'll connect controls
Expand Down
3 changes: 1 addition & 2 deletions dymos/transcriptions/pseudospectral/gauss_lobatto.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GaussLobatto(PseudospectralBase):
High-Order Gauss-Lobatto Quadrature Rules." Journal of Guidance, Control, and
Dynamics 19.3 (1996): 592-599.
"""
def setup_grid(self, phase):
def init_grid(self):
self.grid_data = GridData(num_segments=self.options['num_segments'],
transcription='gauss-lobatto',
transcription_order=self.options['order'],
Expand Down Expand Up @@ -447,7 +447,6 @@ def setup_timeseries_outputs(self, phase):
if options['transcription'] is None:
ogd = None
else:
options['transcription'].setup_grid(phase)
ogd = options['transcription'].grid_data

timeseries_comp = PseudospectralTimeseriesOutputComp(input_grid_data=gd,
Expand Down
3 changes: 1 addition & 2 deletions dymos/transcriptions/pseudospectral/radau_pseudospectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Radau(PseudospectralBase):
Control Problems Using a Radau Pseudospectral Method." American Institute of Aeronautics
and Astronautics, 2009.
"""
def setup_grid(self, phase):
def init_grid(self):
self.grid_data = GridData(num_segments=self.options['num_segments'],
transcription='radau-ps',
transcription_order=self.options['order'],
Expand Down Expand Up @@ -309,7 +309,6 @@ def setup_timeseries_outputs(self, phase):
if options['transcription'] is None:
ogd = None
else:
options['transcription'].setup_grid(phase)
ogd = options['transcription'].grid_data

timeseries_comp = PseudospectralTimeseriesOutputComp(input_grid_data=gd,
Expand Down
3 changes: 1 addition & 2 deletions dymos/transcriptions/runge_kutta/runge_kutta.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def initialize(self):
desc='The options passed to the nonlinear solver used to converge the'
'Runge-Kutta propagation across each step.')

def setup_grid(self, phase):
def init_grid(self):
self.grid_data = GridData(num_segments=self.options['num_segments'],
transcription='runge-kutta',
transcription_order=self.options['method'],
Expand Down Expand Up @@ -685,7 +685,6 @@ def setup_timeseries_outputs(self, phase):
if options['transcription'] is None:
ogd = None
else:
options['transcription'].setup_grid(phase)
ogd = options['transcription'].grid_data

timeseries_comp = RungeKuttaTimeseriesOutputComp(input_grid_data=gd,
Expand Down
2 changes: 1 addition & 1 deletion dymos/transcriptions/solve_ivp/solve_ivp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def initialize(self):
'segment. If an int (n) then results are provided at n '
'equally distributed points in time within each segment.')

def setup_grid(self, phase):
def init_grid(self):
pass

def setup_time(self, phase):
Expand Down
11 changes: 4 additions & 7 deletions dymos/transcriptions/transcription_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,21 @@ def __init__(self, **kwargs):
self._declare_options()
self.initialize()
self.options.update(kwargs)
self.init_grid()

def _declare_options(self):
pass

def initialize(self):
pass

def setup_grid(self, phase):
def init_grid(self):
"""
Setup the GridData object for the Transcription
Parameters
----------
phase
The phase to which this transcription applies.
"""

raise NotImplementedError('Transcription {0} does not implement method'
'setup_grid.'.format(self.__class__.__name__))
'init_grid.'.format(self.__class__.__name__))

def setup_time(self, phase):
"""
Expand Down

0 comments on commit 9aa819e

Please sign in to comment.