openmdao/core/total_jac.py
def compute_totals(self):
        """
        Compute derivatives of desired quantities with respect to desired inputs.

        Returns
        -------
        derivs : object
            Derivatives in form requested by 'return_format'.
        """
        debug_print = self.debug_print
        par_deriv = self.par_deriv

        has_lin_cons = self.has_lin_cons

        model = self.model
        vec_dinput = model._vectors['input']
        vec_doutput = model._vectors['output']
        vec_dresid = model._vectors['residual']

        # Prepare model for calculation by cleaning out the derivatives
        # vectors.
        for vec_name in model._lin_vec_names:
            vec_dinput[vec_name]._data[:] = 0.0
            vec_doutput[vec_name]._data[:] = 0.0
            vec_dresid[vec_name]._data[:] = 0.0

        # Linearize Model
        model._linearize(model._assembled_jac, sub_do_ln=model._linear_solver._linearize_children())
        model._linear_solver._linearize()

        # Main loop over columns (fwd) or rows (rev) of the jacobian
        for mode in self.idx_iter_dict:
            for key, idx_info in iteritems(self.idx_iter_dict[mode]):
                imeta, idx_iter = idx_info
                for inds, input_setter, jac_setter, itermeta in idx_iter(imeta, mode):

                    rel_systems, vec_names, cache_key = input_setter(inds, itermeta, mode)

                    if debug_print:
                        if par_deriv and key in par_deriv:
                            varlist = '(' + ', '.join([name for name in par_deriv[key]]) + ')'
                            print('Solving color:', key, varlist)
                        else:
                            print('Solving variable:', key)

                        sys.stdout.flush()
                        t0 = time.time()

                    # restore old linear solution if cache_linear_solution was set by the user for
                    # any input variables involved in this linear solution.
                    if cache_key is not None and not has_lin_cons:
                        self._restore_linear_solution(vec_names, cache_key, self.mode)
                        model._solve_linear(model._lin_vec_names, self.mode, rel_systems)
                        self._save_linear_solution(vec_names, cache_key, self.mode)
                    else:
                        model._solve_linear(model._lin_vec_names, mode, rel_systems)

                    if debug_print:
                        print('Elapsed Time:', time.time() - t0, '\n')
                        sys.stdout.flush()

                    jac_setter(inds, mode)

        if self.has_scaling:
            self._do_scaling(self.J_dict)

        if debug_print:
            # Debug outputs scaled derivatives.
            self._print_derivatives()

        # np.save("total_jac.npy", self.J)

        return self.J_final

        Compute derivatives of desired quantities with respect to desired inputs.

        Returns
        -------
        derivs : object
            Derivatives in form requested by 'return_format'.
        
Compute derivatives of desired quantities with respect to desired inputs.
Returns

derivs : object
Derivatives in form requested by 'return_format'.
Compute derivatives of desired quantities with respect to desired inputs . Returns derivs : object Derivatives in form requested by ' return_format ' .
def compute_totals(self):
        debug_print = self.debug_print
        par_deriv = self.par_deriv
        has_lin_cons = self.has_lin_cons
        model = self.model
        vec_dinput = model._vectors['input']
        vec_doutput = model._vectors['output']
        vec_dresid = model._vectors['residual']
        for vec_name in model._lin_vec_names:
            vec_dinput[vec_name]._data[:] = 0.0
            vec_doutput[vec_name]._data[:] = 0.0
            vec_dresid[vec_name]._data[:] = 0.0
        model._linearize(model._assembled_jac, sub_do_ln=model._linear_solver._linearize_children())
        model._linear_solver._linearize()
        for mode in self.idx_iter_dict:
            for key, idx_info in iteritems(self.idx_iter_dict[mode]):
                imeta, idx_iter = idx_info
                for inds, input_setter, jac_setter, itermeta in idx_iter(imeta, mode):
                    rel_systems, vec_names, cache_key = input_setter(inds, itermeta, mode)
                    if debug_print:
                        if par_deriv and key in par_deriv:
                            varlist = '(' + ', '.join([name for name in par_deriv[key]]) + ')'
                            print('Solving color:', key, varlist)
                        else:
                            print('Solving variable:', key)
                        sys.stdout.flush()
                        t0 = time.time()
                    if cache_key is not None and not has_lin_cons:
                        self._restore_linear_solution(vec_names, cache_key, self.mode)
                        model._solve_linear(model._lin_vec_names, self.mode, rel_systems)
                        self._save_linear_solution(vec_names, cache_key, self.mode)
                    else:
                        model._solve_linear(model._lin_vec_names, mode, rel_systems)
                    if debug_print:
                        print('Elapsed Time:', time.time() - t0, '\n')
                        sys.stdout.flush()
                    jac_setter(inds, mode)
        if self.has_scaling:
            self._do_scaling(self.J_dict)
        if debug_print:
            self._print_derivatives()
        return self.J_final
def compute_totals ( self ) : debug_print = self . debug_print par_deriv = self . par_deriv has_lin_cons = self . has_lin_cons model = self . model vec_dinput = model . _vectors [ 'input' ] vec_doutput = model . _vectors [ 'output' ] vec_dresid = model . _vectors [ 'residual' ] for vec_name in model . _lin_vec_names : vec_dinput [ vec_name ] . _data [ : ] = 0.0 vec_doutput [ vec_name ] . _data [ : ] = 0.0 vec_dresid [ vec_name ] . _data [ : ] = 0.0 model . _linearize ( model . _assembled_jac , sub_do_ln = model . _linear_solver . _linearize_children ( ) ) model . _linear_solver . _linearize ( ) for mode in self . idx_iter_dict : for key , idx_info in iteritems ( self . idx_iter_dict [ mode ] ) : imeta , idx_iter = idx_info for inds , input_setter , jac_setter , itermeta in idx_iter ( imeta , mode ) : rel_systems , vec_names , cache_key = input_setter ( inds , itermeta , mode ) if debug_print : if par_deriv and key in par_deriv : varlist = '(' + ', ' . join ( [ name for name in par_deriv [ key ] ] ) + ')' print ( 'Solving color:' , key , varlist ) else : print ( 'Solving variable:' , key ) sys . stdout . flush ( ) t0 = time . time ( ) if cache_key is not None and not has_lin_cons : self . _restore_linear_solution ( vec_names , cache_key , self . mode ) model . _solve_linear ( model . _lin_vec_names , self . mode , rel_systems ) self . _save_linear_solution ( vec_names , cache_key , self . mode ) else : model . _solve_linear ( model . _lin_vec_names , mode , rel_systems ) if debug_print : print ( 'Elapsed Time:' , time . time ( ) - t0 , '\n' ) sys . stdout . flush ( ) jac_setter ( inds , mode ) if self . has_scaling : self . _do_scaling ( self . J_dict ) if debug_print : self . _print_derivatives ( ) return self . J_final
Compute derivatives of desired quantities with respect to desired inputs.
Compute derivatives of desired quantities with respect to desired inputs .
"""
        Compute derivatives of desired quantities with respect to desired inputs.

        Returns
        -------
        derivs : object
            Derivatives in form requested by 'return_format'.
        """ # Prepare model for calculation by cleaning out the derivatives # vectors. # Linearize Model # Main loop over columns (fwd) or rows (rev) of the jacobian # restore old linear solution if cache_linear_solution was set by the user for # any input variables involved in this linear solution. # Debug outputs scaled derivatives. # np.save("total_jac.npy", self.J)
self