openmdao/jacobians/assembled_jacobian.py
def _initialize(self, system):
        """
        Allocate the global matrices.

        Parameters
        ----------
        system : System
            Parent system to this jacobian.
        """
        # var_indices are the *global* indices for variables on this proc
        is_top = system.pathname == ''

        abs2meta = system._var_abs2meta

        self._int_mtx = int_mtx = self._matrix_class(system.comm)
        ext_mtx = self._matrix_class(system.comm)

        iproc = system.comm.rank
        abs2idx = system._var_allprocs_abs2idx['nonlinear']
        out_sizes = system._var_sizes['nonlinear']['output']
        in_sizes = system._var_sizes['nonlinear']['input']
        out_ranges = self._out_ranges
        in_ranges = self._in_ranges

        abs2prom_out = system._var_abs2prom['output']
        conns = {} if isinstance(system, Component) else system._conn_global_abs_in2out
        keymap = self._keymap
        abs_key2shape = self._abs_key2shape

        # create the matrix subjacs
        for abs_key, info in iteritems(self._subjacs_info):
            res_abs_name, wrt_abs_name = abs_key
            # because self._subjacs_info is shared among all 'related' assembled jacs,
            # we use out_ranges (and later in_ranges) to weed out keys outside of this jac
            if res_abs_name not in out_ranges:
                continue
            res_offset, _ = out_ranges[res_abs_name]

            if wrt_abs_name in abs2prom_out:
                out_offset, _ = out_ranges[wrt_abs_name]
                int_mtx._add_submat(abs_key, info, res_offset, out_offset, None, info['shape'])
                keymap[abs_key] = abs_key
            elif wrt_abs_name in in_ranges:
                if wrt_abs_name in conns:  # connected input
                    out_abs_name = conns[wrt_abs_name]
                    # calculate unit conversion
                    in_units = abs2meta[wrt_abs_name]['units']
                    out_units = abs2meta[out_abs_name]['units']
                    if in_units and out_units and in_units != out_units:
                        factor, _ = get_conversion(out_units, in_units)
                        if factor == 1.0:
                            factor = None
                    else:
                        factor = None

                    out_offset, _ = out_ranges[out_abs_name]
                    src_indices = abs2meta[wrt_abs_name]['src_indices']

                    # need to add an entry for d(output)/d(source)
                    # instead of d(output)/d(input)
                    abs_key2 = (res_abs_name, out_abs_name)
                    keymap[abs_key] = abs_key2

                    if src_indices is None:
                        shape = info['shape']
                    else:
                        shape = abs_key2shape(abs_key2)

                    int_mtx._add_submat(abs_key, info, res_offset, out_offset,
                                        src_indices, shape, factor)

                elif not is_top:  # input is connected to something outside current system
                    ext_mtx._add_submat(abs_key, info, res_offset,
                                        in_ranges[wrt_abs_name][0], None, info['shape'])

        iproc = system.comm.rank
        out_size = np.sum(out_sizes[iproc, :])

        int_mtx._build(out_size, out_size, in_ranges, out_ranges)
        if ext_mtx._submats:
            in_size = np.sum(in_sizes[iproc, :])
            ext_mtx._build(out_size, in_size, in_ranges, out_ranges)
        else:
            ext_mtx = None

        self._ext_mtx[system.pathname] = ext_mtx

        Allocate the global matrices.

        Parameters
        ----------
        system : System
            Parent system to this jacobian.
        
Allocate the global matrices.
Parameters

system : System
Parent system to this jacobian.
Allocate the global matrices . Parameters system : System Parent system to this jacobian .
def _initialize(self, system):
        is_top = system.pathname == ''
        abs2meta = system._var_abs2meta
        self._int_mtx = int_mtx = self._matrix_class(system.comm)
        ext_mtx = self._matrix_class(system.comm)
        iproc = system.comm.rank
        abs2idx = system._var_allprocs_abs2idx['nonlinear']
        out_sizes = system._var_sizes['nonlinear']['output']
        in_sizes = system._var_sizes['nonlinear']['input']
        out_ranges = self._out_ranges
        in_ranges = self._in_ranges
        abs2prom_out = system._var_abs2prom['output']
        conns = {} if isinstance(system, Component) else system._conn_global_abs_in2out
        keymap = self._keymap
        abs_key2shape = self._abs_key2shape
        for abs_key, info in iteritems(self._subjacs_info):
            res_abs_name, wrt_abs_name = abs_key
            if res_abs_name not in out_ranges:
                continue
            res_offset, _ = out_ranges[res_abs_name]
            if wrt_abs_name in abs2prom_out:
                out_offset, _ = out_ranges[wrt_abs_name]
                int_mtx._add_submat(abs_key, info, res_offset, out_offset, None, info['shape'])
                keymap[abs_key] = abs_key
            elif wrt_abs_name in in_ranges:
                if wrt_abs_name in conns:  
                    out_abs_name = conns[wrt_abs_name]
                    in_units = abs2meta[wrt_abs_name]['units']
                    out_units = abs2meta[out_abs_name]['units']
                    if in_units and out_units and in_units != out_units:
                        factor, _ = get_conversion(out_units, in_units)
                        if factor == 1.0:
                            factor = None
                    else:
                        factor = None
                    out_offset, _ = out_ranges[out_abs_name]
                    src_indices = abs2meta[wrt_abs_name]['src_indices']
                    abs_key2 = (res_abs_name, out_abs_name)
                    keymap[abs_key] = abs_key2
                    if src_indices is None:
                        shape = info['shape']
                    else:
                        shape = abs_key2shape(abs_key2)
                    int_mtx._add_submat(abs_key, info, res_offset, out_offset,
                                        src_indices, shape, factor)
                elif not is_top:  
                    ext_mtx._add_submat(abs_key, info, res_offset,
                                        in_ranges[wrt_abs_name][0], None, info['shape'])
        iproc = system.comm.rank
        out_size = np.sum(out_sizes[iproc, :])
        int_mtx._build(out_size, out_size, in_ranges, out_ranges)
        if ext_mtx._submats:
            in_size = np.sum(in_sizes[iproc, :])
            ext_mtx._build(out_size, in_size, in_ranges, out_ranges)
        else:
            ext_mtx = None
        self._ext_mtx[system.pathname] = ext_mtx
def _initialize ( self , system ) : is_top = system . pathname == '' abs2meta = system . _var_abs2meta self . _int_mtx = int_mtx = self . _matrix_class ( system . comm ) ext_mtx = self . _matrix_class ( system . comm ) iproc = system . comm . rank abs2idx = system . _var_allprocs_abs2idx [ 'nonlinear' ] out_sizes = system . _var_sizes [ 'nonlinear' ] [ 'output' ] in_sizes = system . _var_sizes [ 'nonlinear' ] [ 'input' ] out_ranges = self . _out_ranges in_ranges = self . _in_ranges abs2prom_out = system . _var_abs2prom [ 'output' ] conns = { } if isinstance ( system , Component ) else system . _conn_global_abs_in2out keymap = self . _keymap abs_key2shape = self . _abs_key2shape for abs_key , info in iteritems ( self . _subjacs_info ) : res_abs_name , wrt_abs_name = abs_key if res_abs_name not in out_ranges : continue res_offset , _ = out_ranges [ res_abs_name ] if wrt_abs_name in abs2prom_out : out_offset , _ = out_ranges [ wrt_abs_name ] int_mtx . _add_submat ( abs_key , info , res_offset , out_offset , None , info [ 'shape' ] ) keymap [ abs_key ] = abs_key elif wrt_abs_name in in_ranges : if wrt_abs_name in conns : out_abs_name = conns [ wrt_abs_name ] in_units = abs2meta [ wrt_abs_name ] [ 'units' ] out_units = abs2meta [ out_abs_name ] [ 'units' ] if in_units and out_units and in_units != out_units : factor , _ = get_conversion ( out_units , in_units ) if factor == 1.0 : factor = None else : factor = None out_offset , _ = out_ranges [ out_abs_name ] src_indices = abs2meta [ wrt_abs_name ] [ 'src_indices' ] abs_key2 = ( res_abs_name , out_abs_name ) keymap [ abs_key ] = abs_key2 if src_indices is None : shape = info [ 'shape' ] else : shape = abs_key2shape ( abs_key2 ) int_mtx . _add_submat ( abs_key , info , res_offset , out_offset , src_indices , shape , factor ) elif not is_top : ext_mtx . _add_submat ( abs_key , info , res_offset , in_ranges [ wrt_abs_name ] [ 0 ] , None , info [ 'shape' ] ) iproc = system . comm . rank out_size = np . sum ( out_sizes [ iproc , : ] ) int_mtx . _build ( out_size , out_size , in_ranges , out_ranges ) if ext_mtx . _submats : in_size = np . sum ( in_sizes [ iproc , : ] ) ext_mtx . _build ( out_size , in_size , in_ranges , out_ranges ) else : ext_mtx = None self . _ext_mtx [ system . pathname ] = ext_mtx
Allocate the global matrices.
Allocate the global matrices .
"""
        Allocate the global matrices.

        Parameters
        ----------
        system : System
            Parent system to this jacobian.
        """ # var_indices are the *global* indices for variables on this proc # create the matrix subjacs # because self._subjacs_info is shared among all 'related' assembled jacs, # we use out_ranges (and later in_ranges) to weed out keys outside of this jac # connected input # calculate unit conversion # need to add an entry for d(output)/d(source) # instead of d(output)/d(input) # input is connected to something outside current system
self
system