Skip to content

Commit

Permalink
Merge branch 'test' into tensorial
Browse files Browse the repository at this point in the history
  • Loading branch information
wlmb committed Sep 23, 2024
2 parents 07a818f + f89b6eb commit a5ff266
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 29 deletions.
2 changes: 2 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Changes
data/black.png
data/half.png
data/white.png
examples/WE/ST/anisotropy.pl
examples/LE/NR2/epsM-L.pl
examples/LE/NR2/field.pl
examples/LE/NR2/honeycomb.pl
Expand Down Expand Up @@ -73,6 +74,7 @@ t/allh-s.t
t/allh-store.t
t/allh-st.t
t/allh-wer2.t
t/allh-west.t
t/allh-wes.t
t/allh-writest.t
t/cgtsv.t
Expand Down
4 changes: 3 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ WriteMakefile(
'Storable' => '0',
},
TEST_REQUIRES => {
'Machine::Epsilon' => '0',
'Machine::Epsilon' => '0',
'Test::More' => '0',
'Test::Version' => '1.003001'

},
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '0',
Expand Down
37 changes: 37 additions & 0 deletions examples/WE/ST/anisotropy.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Obtain the Green's function for the wave equation and the dielectric tensor
# for a Bouligand-like structure of 3 repeated and rotated anisotropic layers.
use v5.36;
use PDL;
use PDL::NiceSlice;
use PDL::Constants qw(PI);
use Photonic::Geometry::FromEpsilonTensor;
use Photonic::WE::ST::Metric;
use Photonic::WE::ST::Haydock;
use Photonic::WE::ST::Green;
use Photonic::WE::ST::GreenP;
my $nh=10;
my $rot=pdl[[cos(2*PI/3), -sin(2*PI/3), 0],
[sin(2*PI/3), cos(2*PI/3), 0],
[0, 0, 1]];
my $ea=(pdl[[2,0,0],
[0,1,0],
[0,0,1]])->r2C;
my $eb=$rot x $ea x $rot->transpose;
my $ec=$rot x $eb x $rot->transpose;
my $epsilon=pdl($ea, $eb, $ec) # j,i,nz
->(:,:,*1,*1); # j,i,nx,ny,nz
my $epsilonRef=pdl(1);
my $geometry=Photonic::Geometry::FromEpsilonTensor->new(
epsilon=>$epsilon);
my $wavenumber=pdl(.05);
my $wavevector=pdl(0,0,.02); # different from wavenumber
my $metric=Photonic::WE::ST::Metric->new(
geometry=>$geometry, epsilon=>$epsilonRef, wavenumber=>$wavenumber, wavevector=>$wavevector
);

#my $haydock=Photonic::WE::ST::Haydock->new(metric=>$metric, polarization=>$polarization, nh=>$nh);
my $greenObj=Photonic::WE::ST::Green->new(metric=>$metric, nh=>$nh);
my $green=$greenObj->greenTensor;
say $green;
my $epsM=$greenObj->epsilonTensor;
say $epsM;
4 changes: 2 additions & 2 deletions lib/Photonic/LE/ST/EpsL.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Photonic::LE::ST::EpsL;
$Photonic::LE::ST::EpsL::VERSION = '0.021';
$Photonic::LE::ST::EpsL::VERSION = '0.022';

=encoding UTF-8
Expand All @@ -9,7 +9,7 @@ Photonic::LE::ST::EpsL
=head1 VERSION
version 0.021
version 0.022
=head1 COPYRIGHT NOTICE
Expand Down
4 changes: 2 additions & 2 deletions lib/Photonic/LE/ST/EpsTensor.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Photonic::LE::ST::EpsTensor;
$Photonic::LE::ST::EpsTensor::VERSION = '0.021';
$Photonic::LE::ST::EpsTensor::VERSION = '0.022';

=encoding UTF-8
Expand All @@ -9,7 +9,7 @@ Photonic::LE::ST::EpsTensor
=head1 VERSION
version 0.021
version 0.022
=head1 COPYRIGHT NOTICE
Expand Down
4 changes: 2 additions & 2 deletions lib/Photonic/LE/ST/Field.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Photonic::LE::ST::Field;
$Photonic::LE::ST::Field::VERSION = '0.021';
$Photonic::LE::ST::Field::VERSION = '0.022';

=encoding UTF-8
Expand All @@ -9,7 +9,7 @@ Photonic::LE::ST::Field
=head1 VERSION
version 0.021
version 0.022
=head1 COPYRIGHT NOTICE
Expand Down
4 changes: 2 additions & 2 deletions lib/Photonic/LE/ST/Haydock.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Photonic::LE::ST::Haydock;
$Photonic::LE::ST::Haydock::VERSION = '0.021';
$Photonic::LE::ST::Haydock::VERSION = '0.022';

=encoding UTF-8
Expand All @@ -9,7 +9,7 @@ Photonic::LE::S::Haydock
=head1 VERSION
version 0.021
version 0.022
=head1 COPYRIGHT NOTICE
Expand Down
4 changes: 2 additions & 2 deletions lib/Photonic/WE/ST/Field.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Photonic::WE::ST::Field;
$Photonic::WE::ST::Field::VERSION = '0.021';
$Photonic::WE::ST::Field::VERSION = '0.022';

=encoding UTF-8
Expand All @@ -9,7 +9,7 @@ Photonic::WE::ST::Field
=head1 VERSION
version 0.021
version 0.022
=head1 COPYRIGHT NOTICE
Expand Down
4 changes: 2 additions & 2 deletions lib/Photonic/WE/ST/Green.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Photonic::WE::ST::Green;
$Photonic::WE::ST::Green::VERSION = '0.021';
$Photonic::WE::ST::Green::VERSION = '0.022';

=encoding UTF-8
Expand All @@ -9,7 +9,7 @@ Photonic::WE::ST::Green
=head1 VERSION
version 0.021
version 0.022
=head1 COPYRIGHT NOTICE
Expand Down
4 changes: 2 additions & 2 deletions lib/Photonic/WE/ST/GreenP.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Photonic::WE::ST::GreenP;
$Photonic::WE::ST::GreenP::VERSION = '0.021';
$Photonic::WE::ST::GreenP::VERSION = '0.022';

=encoding UTF-8
Expand All @@ -9,7 +9,7 @@ Photonic::WE::ST::GreenP
=head1 VERSION
version 0.021
version 0.022
=head1 COPYRIGHT NOTICE
Expand Down
4 changes: 2 additions & 2 deletions lib/Photonic/WE/ST/Haydock.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Photonic::WE::ST::Haydock;
$Photonic::WE::ST::Haydock::VERSION = '0.021';
$Photonic::WE::ST::Haydock::VERSION = '0.022';

=encoding UTF-8
Expand All @@ -9,7 +9,7 @@ Photonic::WE::ST::Haydock
=head1 VERSION
version 0.021
version 0.022
=head1 SYNOPSIS
Expand Down
4 changes: 2 additions & 2 deletions lib/Photonic/WE/ST/Metric.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Photonic::WE::ST::Metric;
$Photonic::WE::ST::Metric::VERSION = '0.021';
$Photonic::WE::ST::Metric::VERSION = '0.022';

=encoding UTF-8
Expand All @@ -9,7 +9,7 @@ Photonic::WE::ST::Metric
=head1 VERSION
version 0.021
version 0.022
=head1 COPYRIGHT NOTICE
Expand Down
3 changes: 3 additions & 0 deletions t/00-load.t
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Photonic
Photonic::CharacteristicFunctions
Photonic::Geometry::FromB
Photonic::Geometry::FromEpsilon
Photonic::Geometry::FromEpsilonTensor
Photonic::Geometry::FromImage2D
Photonic::LE::NP::EpsL
Photonic::LE::NP::EpsTensor
Expand Down Expand Up @@ -87,6 +88,8 @@ Photonic::WE::ST::GreenP
Photonic::WE::ST::Haydock
Photonic::WE::ST::Metric
);


foreach(@mods){
use_ok( $_ ) || print "Bail out!\n";
}
Expand Down
22 changes: 13 additions & 9 deletions t/allh-st.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ $a->run;
my $as=$a->as;
my $bs=$a->bs;
my $b2s=$a->b2s;
is($a->iteration, 2, "Number of iterations 1D longitudinal");
ok(Cagree($b2s->slice("(0)"), r2C(1)), "1D L b_0^2");
ok(Cagree($as, pdl([$ea*(1-$f)+$eb*$f, $ea*$f+$eb*(1-$f)])), "1D L a");
ok(Cagree($b2s->slice("(1)"), ($eb-$ea)**2*$f*(1-$f)), "1D L b_1^2");
ok(Cagree($b2s, $bs**2), "1D L b2==b^2");
{
is($a->iteration, 2, "Number of iterations 1D longitudinal");
ok(Cagree($b2s->slice("(0)"), r2C(1)), "1D L b_0^2");
ok(Cagree($as, pdl([$ea*(1-$f)+$eb*$f, $ea*$f+$eb*(1-$f)])), "1D L a");
ok(Cagree($b2s->slice("(1)"), ($eb-$ea)**2*$f*(1-$f)), "1D L b_1^2");
ok(Cagree($b2s, $bs**2), "1D L b2==b^2");
}

#View 1D system as 2D, isotropic but tensorial. Transverse direction
my $epst=($ea*identity(2)*(zeroes(2,2,11,1)->zvals<5)
Expand All @@ -68,10 +70,12 @@ $at->run;
my $ast=$at->as;
my $bst=$at->bs;
my $b2st=$at->b2s;
is($at->iteration, 1, "Number of iterations 1D trans");
ok(Cagree($b2st->slice("(0)"), 1), "1D T b_0^2");
ok(Cagree($ast->slice("(0)"), $ea*(1-$f)+$eb*$f), "1D T a_0");
ok(Cagree($b2st, $bst**2), "1D T b2==b^2");
{
is($at->iteration, 1, "Number of iterations 1D trans");
ok(Cagree($b2st->slice("(0)"), 1), "1D T b_0^2");
ok(Cagree($ast->slice("(0)"), $ea*(1-$f)+$eb*$f), "1D T a_0");
ok(Cagree($b2st, $bst**2), "1D T b2==b^2");
}

{
#check reorthogonalize with square array
Expand Down
3 changes: 2 additions & 1 deletion xt/version.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ use warnings;
use Test::More;

## no critic
eval q{use Test::Version 1.003001 qw( version_all_ok ), {
# eval q{use Test::Version 1.003001 qw( version_all_ok ), {
eval q{use Test::Version qw( version_all_ok ), {
is_strict => 1,
has_version => 1,
consistent => 1,
Expand Down

0 comments on commit a5ff266

Please sign in to comment.