Skip to content

Commit

Permalink
switch type system to Type::Tiny
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Oct 2, 2021
1 parent 1a0a04b commit 0387784
Show file tree
Hide file tree
Showing 32 changed files with 269 additions and 251 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- separate storeAllFN from stateFN
- Haydock states stored in memory-mapped files rather than using Storable
- remove the state_iterator capability which is replaced by memory-mapping, allowing large threaded calculations
- switch type system to Type::Tiny

0.021 2021-10-01
- Add example of honeycomb lattice for LE::NR2
Expand Down
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ WriteMakefile(
'Machine::Epsilon' => '0',
'Moose' => '0',
'Moose::Role' => '0',
'Moose::Util::TypeConstraints' => '0',
'Type::Tiny' => '0',
'MooseX::StrictConstructor' => '0',
'PDL' => '2.049', # PDL::Complex->from_native
'PDL::Constants' => '0',
Expand Down
3 changes: 2 additions & 1 deletion lib/Photonic/Geometry/FromB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA

use namespace::autoclean;
use Moose;
use Photonic::Types -all;
use MooseX::StrictConstructor;

has 'B' =>(is=>'ro', isa=>'PDL', required=>1,
has 'B' =>(is=>'ro', isa=>PDLObj, required=>1,
documentation=>'Characteristic function');

with 'Photonic::Roles::Geometry';
Expand Down
6 changes: 3 additions & 3 deletions lib/Photonic/Geometry/FromEpsilon.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ use namespace::autoclean;
use Carp;
use Moose;
use MooseX::StrictConstructor;
use Photonic::Types;
use Photonic::Types -all;

has 'epsilon'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', required=>1,
has 'epsilon'=>(is=>'ro', isa=>PDLComplex, required=>1,
documentation=>'Dielectric function as function of position');

has 'B' =>(is=>'ro', isa=>'PDL', init_arg=>undef, builder=>'_B', lazy=>1,
has 'B' =>(is=>'ro', isa=>PDLObj, init_arg=>undef, builder=>'_B', lazy=>1,
documentation=>'Characteristic function');

with 'Photonic::Roles::Geometry';
Expand Down
3 changes: 2 additions & 1 deletion lib/Photonic/LE/NP/EpsTensor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ for each pixel of the system
use namespace::autoclean;
use Photonic::LE::NP::Haydock;
use Photonic::LE::NP::EpsL;
use Photonic::Types -all;
use Moose;
use MooseX::StrictConstructor;

Expand All @@ -81,7 +82,7 @@ has allh_attrs=>(is=>'ro', default=>sub{[qw(reorthogonalize epsilon)]});
has epsl_class=>(is=>'ro', default=>'Photonic::LE::NP::EpsL');
has epsl_attrs=>(is=>'ro', default=>sub{[qw(nh smallE)]});

has 'epsilon'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', required=>1);
has 'epsilon'=>(is=>'ro', isa=>PDLComplex, required=>1);

with 'Photonic::Roles::EpsTensor', 'Photonic::Roles::KeepStates';

Expand Down
6 changes: 3 additions & 3 deletions lib/Photonic/LE/NP/Haydock.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ These are provided for roles:
=item * geometry
A Photonic::Types::GeometryG0 object defining the geometry of the system,
A L<Photonic::Types/GeometryG0> object defining the geometry of the system,
the characteristic function and the direction of the G=0 vector. Required.
=item * B ndims dims r G GNorm L scale f
Expand Down Expand Up @@ -109,12 +109,12 @@ Returns zero, as there is no need to change sign.
use namespace::autoclean;
use PDL::Lite;
use Carp;
use Photonic::Types;
use Photonic::Types -all;
use Photonic::Utils qw(EProd any_complex apply_longitudinal_projection);
use Moose;
use MooseX::StrictConstructor;

has 'geometry'=>(is=>'ro', isa => 'Photonic::Types::GeometryG0',
has 'geometry'=>(is=>'ro', isa => GeometryG0,
handles=>[qw(B ndims dims r G GNorm L scale f)],required=>1
);
has 'complexCoeffs'=>(is=>'ro', init_arg=>undef, default=>1,
Expand Down
8 changes: 4 additions & 4 deletions lib/Photonic/LE/NR2/EpsL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The spectral variable used in the last calculation
=cut

use namespace::autoclean;
use Photonic::Types;
use Photonic::Types -all;
use Photonic::Utils qw(lentzCF);

use List::Util qw(min);
Expand All @@ -84,11 +84,11 @@ use MooseX::StrictConstructor;

with 'Photonic::Roles::EpsL';

has 'epsA'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', required => 1,
has 'epsA'=>(is=>'ro', isa=>PDLComplex, required => 1,
documentation=>'Dielectric function of host');
has 'epsB'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', required => 1,
has 'epsB'=>(is=>'ro', isa=>PDLComplex, required => 1,
documentation=>'Dielectric function of inclusions');
has 'u'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', lazy => 1, builder => '_build_u',
has 'u'=>(is=>'ro', isa=>PDLComplex, lazy => 1, builder => '_build_u',
documentation=>'Spectral variable');

sub _build_u {
Expand Down
6 changes: 3 additions & 3 deletions lib/Photonic/LE/NR2/EpsTensor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Dielectric function of component B
use namespace::autoclean;
use Photonic::LE::NR2::Haydock;
use Photonic::LE::NR2::EpsL;
use Photonic::Types;
use Photonic::Types -all;
use Moose;
use MooseX::StrictConstructor;

Expand All @@ -84,9 +84,9 @@ has allh_attrs=>(is=>'ro', default=>sub{[qw(reorthogonalize use_mask mask)]});
has epsl_class=>(is=>'ro', default=>'Photonic::LE::NR2::EpsL');
has epsl_attrs=>(is=>'ro', default=>sub{[qw(nh smallE epsA epsB)]});

has 'epsA'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', required => 1,
has 'epsA'=>(is=>'ro', isa=>PDLComplex, required => 1,
documentation=>'Dielectric function of host');
has 'epsB'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', required => 1,
has 'epsB'=>(is=>'ro', isa=>PDLComplex, required => 1,
documentation=>'Dielectric function of inclusions');

with 'Photonic::Roles::UseMask', 'Photonic::Roles::EpsTensor', 'Photonic::Roles::KeepStates';
Expand Down
24 changes: 12 additions & 12 deletions lib/Photonic/LE/NR2/Field.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Initializes the structure.
$nr Photonic::LE::NR2::Haydock is a Haydock calculator for the
structure, *initialized* with the flag keepStates=>1
(Photonic::Types::HaydockSave, as defined in Photonic::Types).
(L<Photonic::Types/HaydockSave>.
$nh is the maximum number of Haydock coefficients to use.
Expand Down Expand Up @@ -136,30 +136,30 @@ use PDL::Lite;
use PDL::NiceSlice;
use Photonic::LE::NR2::Haydock;
use Photonic::Utils qw(cgtsv GtoR linearCombineIt);
use Photonic::Types;
use Photonic::Types -all;
use Moose;
use MooseX::StrictConstructor;

has 'haydock'=>(is=>'ro', isa=>'Photonic::Types::HaydockSave', required=>1,
has 'haydock'=>(is=>'ro', isa=>HaydockSave, required=>1,
documentation=>'Haydock recursion calculator');
has 'filter'=>(is=>'ro', isa=>'PDL', predicate=>'has_filter',
has 'filter'=>(is=>'ro', isa=>PDLObj, predicate=>'has_filter',
documentation=>'Optional reciprocal space filter');
has 'field'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'field'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
writer=>'_field', documentation=>'Calculated real space field');
has 'epsL' =>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'epsL' =>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
writer=>'_epsL',
documentation=>'Longitudinal dielectric response');
has 'nh' =>(is=>'ro', isa=>'Num', required=>1,
has 'nh' =>(is=>'ro', isa=>Num, required=>1,
documentation=>'Desired no. of Haydock coefficients');
has 'smallH'=>(is=>'ro', isa=>'Num', required=>1, default=>1e-7,
has 'smallH'=>(is=>'ro', isa=>Num, required=>1, default=>1e-7,
documentation=>'Convergence criterium for Haydock coefficients');
has 'smallE'=>(is=>'ro', isa=>'Num', required=>1, default=>1e-7,
has 'smallE'=>(is=>'ro', isa=>Num, required=>1, default=>1e-7,
documentation=>'Convergence criterium for use of Haydock coeff.');
has 'epsA'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef, writer=>'_epsA',
has 'epsA'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef, writer=>'_epsA',
documentation=>'Dielectric function of host');
has 'epsB'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef, writer=>'_epsB',
has 'epsB'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef, writer=>'_epsB',
documentation=>'Dielectric function of inclusions');
has 'u'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef, writer=>'_u',
has 'u'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef, writer=>'_u',
documentation=>'Spectral variable');


Expand Down
6 changes: 3 additions & 3 deletions lib/Photonic/LE/NR2/Haydock.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Consumes L<Photonic::Roles::Haydock>, L<Photonic::Roles::UseMask>
=item * geometry
A Photonic::Types::GeometryG0 object defining the geometry of the system,
A L<Photonic::Types/GeometryG0> object defining the geometry of the system,
the characteristic function and the direction of the G=0 vector. Required.
=item * B ndims dims r G GNorm L scale f
Expand Down Expand Up @@ -108,12 +108,12 @@ Return 0, as there is no need to change sign.
use namespace::autoclean;
use PDL::Lite;
use Carp;
use Photonic::Types;
use Photonic::Types -all;
use Photonic::Utils qw(HProd apply_longitudinal_projection);
use Moose;
use MooseX::StrictConstructor;

has 'geometry'=>(is=>'ro', isa => 'Photonic::Types::GeometryG0',
has 'geometry'=>(is=>'ro', isa => GeometryG0,
handles=>[qw(B dims ndims r G GNorm L scale f)],required=>1);
has 'complexCoeffs'=>(is=>'ro', init_arg=>undef, default=>0,
documentation=>'Haydock coefficients are real');
Expand Down
56 changes: 28 additions & 28 deletions lib/Photonic/LE/NR2/SH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -189,108 +189,108 @@ use PDL::Lite;
use PDL::NiceSlice;
use Photonic::LE::NR2::Haydock;
use Photonic::Utils qw(RtoG GtoR HProd linearCombineIt any_complex cgtsv top_slice mvN);
use Photonic::Types;
use Photonic::Types -all;
use PDL::Constants qw(PI);
use Moose;
use MooseX::StrictConstructor;

has 'shp'=>(is=>'ro', 'isa'=>'Photonic::LE::NR2::SHP', required=>1,
has 'shp'=>(is=>'ro', isa=>InstanceOf['Photonic::LE::NR2::SHP'], required=>1,
handles=>[qw(ndims nrf densityA densityB density haydock)],
documentation=>'Object with invariant part of SHG calculation');
has 'epsA1'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', required=>1,
has 'epsA1'=>(is=>'ro', isa=>PDLComplex, required=>1,
documentation=>'Fundamental dielectric function of host');
has 'epsB1'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex',
has 'epsB1'=>(is=>'ro', isa=>PDLComplex,
documentation=>'Fundamental dielectric function of inclusions');
has 'epsA2'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', required=>1,
has 'epsA2'=>(is=>'ro', isa=>PDLComplex, required=>1,
documentation=>'SH Dielectric function of host');
has 'epsB2'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', required=>1,
has 'epsB2'=>(is=>'ro', isa=>PDLComplex, required=>1,
documentation=>'SH Dielectric function of inclusions');
has 'alpha1'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'alpha1'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_alpha1',
documentation=>'Linear "atomic" polarizability');
has 'alpha2'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'alpha2'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_alpha2',
documentation=>'SH linear "atomic" polarizability');
has 'u1'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'u1'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_u1',
documentation=>'Spectral variable at fundamental');
has 'u2'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'u2'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_u2',
documentation=>'Spectral variable at SH');
has 'field1'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'field1'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_field1',
documentation=>'longitudinal field at fundamental');
has 'field2'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'field2'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_field2',
documentation=>'longitudinal field at second harmonic');
has 'epsL2'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'epsL2'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
writer=>'_epsL2', predicate=>'has_epsL2',
documentation=>'longitudinal dielectric function at 2w');
has 'dipolar'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'dipolar'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_dipolar',
documentation=>'SH dipolar contribution to SH polarization');
has 'quadrupolar'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'quadrupolar'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_quadrupolar',
documentation=>'SH quadrupolar contribution to SH polarization');
has 'external'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'external'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_external',
documentation=>'SH external contribution to SH polarization');
has 'external_G'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'external_G'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_external_G',
documentation=>'SH ext. polarization in reciprocal space');
has 'externalL_G'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'externalL_G'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_externalL_G',
documentation=>
'SH ext. longitudinal polarization comp. in reciprocal space');
has 'externalVecL_G'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'externalVecL_G'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_externalVecL_G',
documentation=>
'SH ext. longitudinal polarization proj. in recip. space');
has 'externalVecL'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'externalVecL'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_externalVecL',
documentation=>
'SH ext. longitudinal polarization proj. in real space');
has 'HP' =>(is=>'ro', isa=>'Photonic::LE::NR2::Haydock', init_arg=>undef,
has 'HP' =>(is=>'ro', isa=>InstanceOf['Photonic::LE::NR2::Haydock'], init_arg=>undef,
lazy=>1, builder=>'_build_HP',
documentation=>
'Structure to calculate Haydock basis for non linear polarization');
has 'externalL_n'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex', init_arg=>undef,
has 'externalL_n'=>(is=>'ro', isa=>PDLComplex, init_arg=>undef,
lazy=>1, builder=>'_build_externalL_n',
documentation=>
'SH ext. longitudinal polarization in Haydock
representation');
has 'selfConsistentL_n'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex',
has 'selfConsistentL_n'=>(is=>'ro', isa=>PDLComplex,
init_arg=>undef, lazy=>1,
builder=>'_build_selfConsistentL_n',
documentation=>
'SH self consistent longitudinal polarization
in Haydock representation');
has 'selfConsistentL_G'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex',
has 'selfConsistentL_G'=>(is=>'ro', isa=>PDLComplex,
init_arg=>undef, lazy=>1,
builder=>'_build_selfConsistentL_G',
documentation=>
'SH self consistent longitudinal polarization components in
reciprocal space');
has 'selfConsistentVecL_G'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex',
has 'selfConsistentVecL_G'=>(is=>'ro', isa=>PDLComplex,
init_arg=>undef, lazy=>1,
builder=>'_build_selfConsistentVecL_G',
documentation=>
'SH self consistent longitudinal polarization vector
field in reciprocal space');
has 'selfConsistentVecL'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex',
has 'selfConsistentVecL'=>(is=>'ro', isa=>PDLComplex,
init_arg=>undef, lazy=>1,
builder=>'_build_selfConsistentVecL',
documentation=>
'SH self consistent longitudinal polarization vector
field in real space');
has 'P2'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex',
has 'P2'=>(is=>'ro', isa=>PDLComplex,
init_arg=>undef, lazy=>1,
builder=>'_build_P2',
documentation=>
'SH self consistent total polarization vector
field in real space');

has 'P2LMCalt'=>(is=>'ro', isa=>'Photonic::Types::PDLComplex',
has 'P2LMCalt'=>(is=>'ro', isa=>PDLComplex,
init_arg=>undef, lazy=>1,
builder=>'_build_P2LMCalt',
documentation=>
Expand Down

0 comments on commit 0387784

Please sign in to comment.