The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Photonic::Roles::Haydock

VERSION

version 0.021

COPYRIGHT NOTICE

Photonic - A perl package for calculations on photonics and metamaterials.

Copyright (C) 2016 by W. Luis Mochán

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA

    mochan@fis.unam.mx

    Instituto de Ciencias Físicas, UNAM
    Apartado Postal 48-3
    62251 Cuernavaca, Morelos
    México

SYNOPSIS

    use Photonic::LE::NR2::Haydock;
    my $nr=Photonic::LE::NR2::Haydock->new(geometry=>$geometry,nh=>$Nh,
            keepStates=>$save);
    $nr->run;
    my $haydock_as=$iter->as;
    my $haydock_bs=$iter->bs;
    my $haydock_b2s=$iter->b2s;

    # or one iteration:
    $nr->iterate;
    say $nr->iteration;
    say $nr->current_a;
    say $nr->next_b2;
    my $state=$nr->next_state;
(for developers)
    package Photonic::LE::NR2::Haydock;
    $Photonic::LE::NR2::Haydock::VERSION= '0.021';
    use namespace::autoclean;
    use Moose;
    has...
    with 'Photonic::Roles::Haydock';

DESCRIPTION

Role consumed by Haydock objects to be used in a Photonic calculation. Basic scheme for the calculation of one Haydock coefficient and one Haydock state at a time.

Iterates the calculation of Haydock coefficients and states and saves them for later retrieval.

Consumes Photonic::Roles::KeepStates, Photonic::Roles::Reorthogonalize - please see those for attributes.

ATTRIBUTES

  • smallH

    A small number used as tolerance to end the iteration. Small negative b^2 coefficients are taken to be zero.

  • current_state next_state

    The n-th and n+1-th Haydock states

  • current_a

    The n-th Haydock coefficient a

  • next_b2 next_b

    The n+1-th b^2 and b Haydock coefficients

  • iteration

    Number of completed iterations

  • nh

    Maximum number of desired Haydock 'a' coefficients and states. The number of b coefficients is one less (but it starts with a dummy zero).

  • keepStates

    Flag to keep (1) or discard (0) Haydock states

  • state_iterator

    Iterator to provide the previously calculated and saved states. It may take the states from memory or from a file if provided.

  • states

    Array of Haydock states

  • as

    ndarray of Haydock a coefficients

  • bs

    ndarray of Haydock b coefficients.

  • b2s

    ndarray of Haydock b coefficients squared

REQUIRED ATTRIBUTES

These must be supplied by the consuming class:

  • applyOperator($psi_G)

    Apply the relevant operator to state $psi_G.

  • innerProduct($left, $right)

    Returns the inner product between states $left and $right.

  • magnitude($psi_G)

    Returns the magnitude of state $psi_G.

  • changesign

    Whether there is a need to change sign.

  • complexCoeffs

    Whether the coefficients are complex.

METHODS

  • iterate

    Performs a single Haydock iteration and updates current_a, next_b, next_b2, next_state, shifting the current values where necessary. Returns 0 when unable to continue iterating.

  • run

    Runs the iteration to completion.

  • loadall

    Load previously saved state from file, if provided.

  • storeall

    Store final state to file, if provided.