def get_bc(self,matrix=None,is_vector=False): '''Calculates Barycenter for scalar field ''' # Initialize variable self.bc = numpy.zeros(3) # Calculation of barycenter from orbkit import grid if not is_vector: grid.grid2vector() xyz = grid.tolist() for i in range(3): self.bc[i] = (matrix.reshape((-1,))*xyz[i]).sum() self.bc /= matrix.sum() if not is_vector: grid.vector2grid(*grid.N_) return self.bc
display.display(grid.get_grid()) # Choose the molecular orbitals to be calculated selected_MO = ['1.1_a', '1.5_a'] qc.mo_spec = read.mo_select(qc.mo_spec, selected_MO, strict=True)['mo_spec'] # Calculate molecular orbitals mo_list = core.rho_compute(qc, calc_mo=True, slice_length=slice_length, drv=None, numproc=numproc) # Calculate analytic derivatives of molecular orbitals mo_list_drv = core.rho_compute(qc, calc_mo=True, slice_length=slice_length, drv='xyz', numproc=numproc) # Calculate Transition Electronic Flux Densities (time independent) # Calculate the STEFD [in units of (i E_h/(hbar a_0^2))] j_stefd = -0.5 * (mo_list[numpy.newaxis, 0] * mo_list_drv[:, 1] - mo_list[numpy.newaxis, 1] * mo_list_drv[:, 0]) Z, Y, X = output.meshgrid2(*grid.tolist()[::-1]) mlab.quiver3d(X, Y, Z, *j_stefd) mlab.show()