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.023

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.023';
use namespace::autoclean;
use Moo;
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

  • stateFN

    File where the states will be read from and stored, memory-mapped. See PDL::IO::FastRaw for more information. Ensure that the geometry dimensions are the same as the states'.

  • storeAllFN

    File in which important attributes will be stored, plus the calculated coefficients. If no stateFN as above is given, one will be assumed that is this value suffixed with .states.

  • loadAllFN

    File from which the attributes, coefficients and states will be loaded. The states will be expected in a file suffixed with .states, and needs to have been memory-mapped as above.

  • 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 next_a

    The n-th and n+1-th Haydock coefficient a

  • current_b2 next_b2 current_b next_b

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

  • current_bc next_bc current_c next_c current_g next_g

    The n-th and n+1-th b*c, c, and g 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

  • states

    ndarray of Haydock states

  • as

    ndarray of Haydock a coefficients

  • bs

    ndarray of Haydock b coefficients.

  • b2s

    ndarray of Haydock b coefficients squared

  • bcs

    ndarray of Haydock b*c coefficients

  • cs

    ndarray of Haydock c coefficients

  • gs

    ndarray of Haydock g coefficients

  • converged

    Flag that the calculation converged

  • reorthogonalize

    Flag that the calculation should be reorthogonalised

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 false when b^2 <= smallH.

  • run

    Runs the iteration to completion.

  • loadall

    Load previously saved state from file, if provided.

  • storeall

    Store final state to file, if provided.