lattice_constructor Function

private function lattice_constructor(lattice_type, length_x, length_y, length_z, t_periodic_x, t_periodic_y, t_periodic_z, space, t_bipartite_order) result(this)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: lattice_type
integer, intent(in) :: length_x
integer, intent(in) :: length_y
integer, intent(in) :: length_z
logical, intent(in) :: t_periodic_x
logical, intent(in) :: t_periodic_y
logical, intent(in) :: t_periodic_z
character(len=*), intent(in), optional :: space
logical, intent(in), optional :: t_bipartite_order

Return Value class(lattice), pointer


Contents

Source Code


Source Code

    function lattice_constructor(lattice_type, length_x, length_y, length_z, t_periodic_x, &
                                 t_periodic_y, t_periodic_z, space, t_bipartite_order) result(this)
        ! write a general public lattice_constructor for lattices
        ! the number of inputs are still undecided.. do we always have
        ! the same number or differing number of inputs?
        ! i guess, since we will be using global variables which are either
        ! read in or set as default to init it..
        character(*), intent(in) :: lattice_type
        integer, intent(in) :: length_x, length_y, length_z
        logical, intent(in) :: t_periodic_x, t_periodic_y, t_periodic_z
        character(*), intent(in), optional :: space
        logical, intent(in), optional :: t_bipartite_order
        class(lattice), pointer :: this
        character(*), parameter :: this_routine = "lattice_constructor"

        select case (lattice_type)
        case ('chain')

            allocate(chain :: this)

        case ('star')

            allocate(star :: this)

        case ('square')
            ! i guess i want to make a seperate case for the tilted
            ! square, although just the boundary conditions change, but also
            ! the length input changes
            if (length_x /= length_y) then
                call stop_all(this_routine, &
                              "incorrect length input for square lattice!")

            end if

            allocate(rectangle :: this)

        case ('rectangle', 'rect')

            allocate(rectangle :: this)

        case ('tilted', 'tilted-square', 'square-tilted')

            allocate(tilted :: this)

        case ('cube', 'cubic')
            ! for the sake of no better name also use "cube" even if the
            ! sides are not the same length

            if (any([length_x, length_y, length_z] < 2)) then
                call stop_all(this_routine, &
                              "too short cube side lengths < 2!")
            end if

            allocate(cube :: this)

        case ('triangular', 'triangle', 'tri')

            if (any([length_x, length_y] < 2)) then
                call stop_all(this_routine, &
                              "too short lengths for triangular lattice! < 2!")
            end if

            allocate(triangular :: this)

        case ('hexagonal', 'hex', 'hexagon', 'honeycomb')

            allocate(hexagonal :: this)

        case ('kagome')
            allocate(kagome :: this)

        case ('ole')
            allocate(ole :: this)

        case ('sujun')
            allocate(sujun :: this)

        case ('ext_input')
            allocate(ext_input :: this)

        case default
            ! stop here because a incorrect lattice type was given
            call stop_all(this_routine, &
                          'incorrect lattice type provided in lattice_constructor!')

        end select

        call this%set_name(lattice_type)

        ! depending on the string input defining lattice type
        ! initialize corresponding lattice
        if (present(space)) then
            select case (space)
            case ('k-space')
                this%t_momentum_space = .true.

            case ('real-space')
                this%t_momentum_space = .false.

            case default
                call stop_all(this_routine, "not recognized space!")

            end select
        end if

        ! the initializer deals with the different types then..
        call this%initialize(length_x, length_y, length_z, &
                             t_periodic_x, t_periodic_y, t_periodic_z, t_bipartite_order)

    end function lattice_constructor