@@ -440,6 +440,62 @@ def _construct_slater(sum_k, general_params, Umat_full_rotated, icrsh):
440440
441441 return h_int
442442
443+ def h_int_simple_intra (spin_names ,n_orb ,U ,off_diag = None ,map_operator_structure = None ,H_dump = None ):
444+ r"""
445+ Create a simple intra orbital density-density Hamiltonian.
446+ (no inter orbital terms)
447+
448+ .. math::
449+ H = \frac{1}{2} \sum_{i \sigma \neq \sigma')} U_{i i}^{\sigma \sigma'} n_{i \sigma} n_{i \sigma'}.
450+
451+ Parameters
452+ ----------
453+ spin_names : list of strings
454+ Names of the spins, e.g. ['up','down'].
455+ n_orb : int
456+ Number of orbitals.
457+ U : float
458+ U value
459+ off_diag : boolean
460+ Do we have (orbital) off-diagonal elements?
461+ If yes, the operators and blocks are denoted by ('spin', 'orbital'),
462+ otherwise by ('spin_orbital',0).
463+ map_operator_structure : dict
464+ Mapping of names of GF blocks names from one convention to another,
465+ e.g. {('up', 0): ('up_0', 0), ('down', 0): ('down_0',0)}.
466+ If provided, the operators and blocks are denoted by the mapping of ``('spin', 'orbital')``.
467+ H_dump : string
468+ Name of the file to which the Hamiltonian should be written.
469+
470+ Returns
471+ -------
472+ H : Operator
473+ The Hamiltonian.
474+
475+ """
476+ from triqs .operators .util .op_struct import get_mkind
477+
478+ if H_dump :
479+ H_dump_file = open (H_dump ,'w' )
480+ H_dump_file .write ("Density-density Hamiltonian:" + '\n ' )
481+
482+ H = Operator ()
483+ mkind = get_mkind (off_diag ,map_operator_structure )
484+ if H_dump : H_dump_file .write ("Density-density terms:" + '\n ' )
485+ for s1 , s2 in product (spin_names ,spin_names ):
486+ if (s1 is not s2 ):
487+ for a1 in range (n_orb ):
488+ H_term = 0.5 * U * n (* mkind (s1 ,a1 )) * n (* mkind (s2 ,a1 ))
489+ H += H_term
490+
491+ # Dump terms of H
492+ if H_dump and not H_term .is_zero ():
493+ H_dump_file .write ('%s' % (mkind (s1 ,a1 ),) + '\t ' )
494+ H_dump_file .write ('%s' % (mkind (s2 ,a1 ),) + '\t ' )
495+ H_dump_file .write (str (U ) + '\n ' )
496+
497+ return H
498+
443499
444500def construct (sum_k , general_params , advanced_params ):
445501 """
@@ -528,6 +584,15 @@ def construct(sum_k, general_params, advanced_params):
528584 h_int [icrsh ] = general_params ['U' ][icrsh ]/ 2.0 * (n_tot_op * n_tot_op - n_tot_op )
529585 continue
530586
587+ if general_params ['h_int_type' ][icrsh ] == 'simple_intra' :
588+ h_int [icrsh ] = h_int_simple_intra (sum_k .spin_block_names [sum_k .SO ],
589+ solver .get_n_orbitals (sum_k )[icrsh ]['up' ],
590+ map_operator_structure = sum_k .sumk_to_solver [icrsh ],
591+ U = general_params ['U' ][icrsh ],
592+ H_dump = os .path .join (general_params ['jobname' ], 'H.txt' ))
593+ continue
594+
595+
531596 # read from file options
532597 if general_params ['h_int_type' ][icrsh ] in ('crpa' , 'crpa_density_density' ):
533598 Umat_full = _load_crpa_interaction_matrix (sum_k , icrsh )
@@ -538,7 +603,7 @@ def construct(sum_k, general_params, advanced_params):
538603
539604 # Rotates the interaction matrix
540605 Umat_full_rotated = _rotate_four_index_matrix (sum_k , general_params , Umat_full , icrsh )
541-
606+
542607 # construct slater / density density from U tensor
543608 if general_params ['h_int_type' ][icrsh ] == 'crpa' :
544609 h_int [icrsh ] = _construct_slater (sum_k , general_params , Umat_full_rotated , icrsh )
0 commit comments