#!/usr/bin/perl
#
# Find combinations of modes which will create standing waves
#    within a certain range of frequencies.
#
# MWR 4/21/2020

$debug = 0;

$mypi = 3.1415926;
$c = 2.99792458E8;
# size of cavity (m)
#$Lx = 0.297;
#$Ly = 0.366;
#$Lz = 0.302;
$Lx = 0.284;
$Ly = 0.195;
$Lz = 0.269;
# limits of frequencies we want (Hz)
$min_freq = 2.400E9;
$max_freq = 2.500E9;
# limits of mode indices
$min_n = 1;
$max_n = 10;


    for ($nx = $min_n; $nx <= $max_n; $nx++) {
      for ($ny = $min_n; $ny <= $max_n; $ny++) { 
        for ($nz = $min_n; $nz <= $max_n; $nz++) { 


          $sq = sqrt( ($nx*$nx/($Lx*$Lx)) + ($ny*$ny/($Ly*$Ly)) 
                         + ($nz*$nz/($Lz*$Lz)) );
          $omega = $mypi*$c*$sq;
          $freq = $omega / (2.0*$mypi);

          if ($debug > 0) {
            printf "# nx %2d  ny %2d  nz %2d   omega %8.4e  freq %8.4e \n",
                 $nx, $ny, $nz, $omega, $freq;
          }

          if (($freq >= $min_freq) && ($freq <= $max_freq)) {
            printf "  nx %2d  ny %2d  nz %2d   omega %8.4e  freq %8.4e \n",
                 $nx, $ny, $nz, $omega, $freq;
          }


        }
      }
    }



exit 0;
         
