How to use the dymos.glm.ozone.utils.units.get_rate_units function in dymos

To help you get started, we’ve selected a few dymos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenMDAO / dymos / dymos / glm / ozone / components / implicit_tm_step_comp.py View on Github external
self.dy_dF = dy_dF = {}

        self.add_input('h', units=time_units)

        for state_name, state in iteritems(self.options['states']):
            size = np.prod(state['shape'])
            shape = state['shape']

            F_name = get_name('F', state_name, i_step=i_step)
            y_old_name = get_name('y_old', state_name, i_step=i_step)
            y_new_name = get_name('y_new', state_name, i_step=i_step)

            self.add_input(
                F_name, shape=(num_stages,) + shape,
                units=get_rate_units(state['units'], time_units))

            self.add_input(
                y_old_name, shape=(num_step_vars,) + shape,
                units=state['units'])

            self.add_output(
                y_new_name, shape=(num_step_vars,) + shape,
                units=state['units'])

            F_arange = np.arange(num_stages * size).reshape(
                (num_stages,) + shape)

            y_arange = np.arange(num_step_vars * size).reshape(
                (num_step_vars,) + shape)

            # -----------------
github OpenMDAO / dymos / dymos / glm / ozone / components / vectorized_step_comp.py View on Github external
F_name = get_name('F', state_name)
            y0_name = get_name('y0', state_name)
            y_name = get_name('y', state_name)

            y0_arange = np.arange(num_step_vars * size).reshape((num_step_vars,) + shape)

            y_arange = np.arange(num_times * num_step_vars * size).reshape(
                (num_times, num_step_vars,) + shape)

            F_arange = np.arange((num_times - 1) * num_stages * size).reshape(
                (num_times - 1, num_stages,) + shape)

            self.add_input(
                F_name,
                shape=(num_times - 1, num_stages,) + shape,
                units=get_rate_units(state['units'], time_units))

            self.add_input(
                y0_name,
                shape=(num_step_vars,) + shape,
                units=state['units'])

            self.add_output(
                y_name,
                shape=(num_times, num_step_vars,) + shape,
                units=state['units'])

            # -----------------

            # (num_times, num_step_vars,) + shape
            data1 = np.ones(num_times * num_step_vars * size)
            rows1 = np.arange(num_times * num_step_vars * size)
github OpenMDAO / dymos / dymos / glm / ozone / components / explicit_tm_stage_comp.py View on Github external
self.declare_partials('*', '*', dependent=False)

        self.add_input('h', units=time_units)

        for state_name, state in iteritems(self.options['states']):
            size = np.prod(state['shape'])

            y_old_name = get_name('y_old', state_name, i_step=i_step, i_stage=i_stage)
            Y_name = get_name('Y', state_name, i_step=i_step, i_stage=i_stage)

            for j_stage in range(i_stage):
                F_name = get_name('F', state_name, i_step=i_step, i_stage=i_stage, j_stage=j_stage)

                self.add_input(
                    F_name, shape=(1,) + state['shape'],
                    units=get_rate_units(state['units'], time_units))

            self.add_input(
                y_old_name, shape=(num_step_vars,) + state['shape'],
                units=state['units'])

            self.add_output(
                Y_name, shape=(1,) + state['shape'],
                units=state['units'])

            vals = np.zeros((num_step_vars, size))
            rows = np.zeros((num_step_vars, size), int)
            cols = np.arange(num_step_vars * size)
            for ii_step in range(num_step_vars):
                vals[ii_step, :] = glm_U[i_stage, ii_step]
                rows[ii_step, :] = np.arange(size)
            vals = vals.flatten()
github OpenMDAO / dymos / dymos / glm / ozone / components / explicit_tm_step_comp.py View on Github external
self.declare_partials('*', '*', dependent=False)

        self.add_input('h', units=time_units)

        for state_name, state in iteritems(self.options['states']):
            size = np.prod(state['shape'])

            y_old_name = get_name('y_old', state_name, i_step=i_step)
            y_new_name = get_name('y_new', state_name, i_step=i_step)

            for j_stage in range(num_stages):
                F_name = get_name('F', state_name, i_step=i_step, j_stage=j_stage)

                self.add_input(
                    F_name, shape=(1,) + state['shape'],
                    units=get_rate_units(state['units'], time_units))

            self.add_input(
                y_old_name, shape=(num_step_vars,) + state['shape'],
                units=state['units'])

            self.add_output(
                y_new_name, shape=(num_step_vars,) + state['shape'],
                units=state['units'])

            self.declare_partials(y_new_name, 'h', dependent=True)

            y_arange = np.arange(num_step_vars * size).reshape((num_step_vars, size))

            # num_step_vars, num_step_vars, size
            data = np.einsum('ij,...->ij...', glm_V, np.ones(size)).flatten()
            rows = np.einsum('i...,j->ij...', y_arange, np.ones(num_step_vars, int)).flatten()
github OpenMDAO / dymos / dymos / glm / ozone / components / implicit_tm_stage_comp.py View on Github external
glm_A = self.options['glm_A']
        glm_U = self.options['glm_U']

        self.add_input('h', units=time_units)

        for state_name, state in iteritems(self.options['states']):
            size = np.prod(state['shape'])
            shape = state['shape']

            F_name = get_name('F', state_name, i_step=i_step)
            y_old_name = get_name('y_old', state_name, i_step=i_step)
            Y_name = get_name('Y', state_name, i_step=i_step)

            self.add_input(
                F_name, shape=(num_stages,) + shape,
                units=get_rate_units(state['units'], time_units))

            self.add_input(
                y_old_name, shape=(num_step_vars,) + shape,
                units=state['units'])

            self.add_output(
                Y_name, shape=(num_stages,) + shape,
                units=state['units'])

            Y_arange = np.arange(num_stages * size).reshape(
                (num_stages,) + shape)

            F_arange = np.arange(num_stages * size).reshape(
                (num_stages,) + shape)

            y_arange = np.arange(num_step_vars * size).reshape(
github OpenMDAO / dymos / dymos / glm / ozone / components / vectorized_stage_comp.py View on Github external
Y_out_name = get_name('Y_out', state_name)
            Y_in_name = get_name('Y_in', state_name)

            Y_arange = np.arange((num_times - 1) * num_stages * size).reshape(
                (num_times - 1, num_stages,) + shape)

            F_arange = np.arange((num_times - 1) * num_stages * size).reshape(
                (num_times - 1, num_stages,) + shape)

            y_arange = np.arange(num_times * num_step_vars * size).reshape(
                (num_times, num_step_vars,) + shape)

            self.add_input(
                F_name,
                shape=(num_times - 1, num_stages,) + shape,
                units=get_rate_units(state['units'], time_units))

            self.add_input(
                y_name,
                shape=(num_times, num_step_vars,) + shape,
                units=state['units'])

            self.add_input(
                Y_in_name, val=0.,
                shape=(num_times - 1, num_stages,) + shape,
                units=state['units'])

            self.add_output(
                Y_out_name,
                shape=(num_times - 1, num_stages,) + shape,
                units=state['units'])
github OpenMDAO / dymos / dymos / glm / ozone / components / vectorized_stagestep_comp.py View on Github external
num_y0 = np.prod(y0_arange.shape)
            num_F = np.prod(F_arange.shape)
            num_Y = np.prod(Y_arange.shape)
            num_y = np.prod(y_arange.shape)

            # --------------------------------------------------------------------------------

            self.add_input(
                y0_name,
                shape=(num_step_vars,) + shape,
                units=state['units'])

            self.add_input(
                F_name,
                shape=(num_times - 1, num_stages,) + shape,
                units=get_rate_units(state['units'], time_units))

            self.add_input(
                Y_in_name, val=0.,
                shape=(num_times - 1, num_stages,) + shape,
                units=state['units'])

            self.add_output(
                Y_out_name,
                shape=(num_times - 1, num_stages,) + shape,
                units=state['units'])

            # -----------------

            self.declare_partials(Y_out_name, 'h_vec')
            self.declare_partials(Y_out_name, y0_name)
            self.declare_partials(Y_out_name, F_name)