summaryrefslogtreecommitdiff
path: root/lpic/src/propagate_fields.C
blob: 7c03fcf4adfbddd12201d37348e085778a79f105 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
   This file is part of LPIC++, a particle-in-cell code for
   simulating the interaction of laser light with plasma.

   Copyright (C) 1994-1997 Roland Lichters

   LPIC++ 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 2
   of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include <propagate.h>

void propagate::fields( domain &grid, pulse &laser_front, pulse &laser_rear )
{
  static error_handler bob("propagate::fields", errname);

  struct cell *cell;
  double fp, fp_old, gm, gm_old;
  double pidt = PI * dt;

  cell=grid.left;

  fp_old   = cell->fp;
  gm_old   = cell->gm;

  if (domain_number==1) {
/*    cell->fp = laser_front.Qy * laser_front.field( time );
    cell->gm = laser_front.Qz * laser_front.field( time + laser_front.shift ); */
    cell->fp = laser_front.field( time , 0 );
    cell->gm = laser_front.field( time , 1 );
  }
  else {
    cell->fp = grid.lbuf->fp - pidt * grid.lbuf->jy;
    cell->gm = grid.lbuf->gm - pidt * grid.lbuf->jz;
  }

  cell->fm = cell->next->fm - pidt * cell->jy;
  cell->gp = cell->next->gp - pidt * cell->jz;

  cell->ey = cell->fp + cell->fm;   cell->ez = cell->gp + cell->gm;
  cell->bz = cell->fp - cell->fm;   cell->by = cell->gp - cell->gm;

  cell->ex -= 2.0 * pidt * cell->jx;

  for( cell=grid.left->next; cell->next!=grid.rbuf; cell=cell->next )
    {
      fp = cell->fp;                                   // could be done in a more elegant
      cell->fp = fp_old - pidt * cell->prev->jy;       // way: i.e. do the loop twice,
      fp_old = fp;                                     // forward for fm and gp,
                                                       // backward for fp and gm
      gm = cell->gm;
      cell->gm = gm_old - pidt * cell->prev->jz;
      gm_old = gm;

      cell->fm = cell->next->fm - pidt * cell->jy;
      cell->gp = cell->next->gp - pidt * cell->jz;

      cell->ey = cell->fp + cell->fm;   cell->bz = cell->fp - cell->fm;
      cell->ez = cell->gp + cell->gm;   cell->by = cell->gp - cell->gm;

      cell->ex -= 2.0 * pidt * cell->jx;
    }

  cell->fp = fp_old - pidt * cell->prev->jy;
  cell->gm = gm_old - pidt * cell->prev->jz;

  if (domain_number==n_domains) {
/*    cell->fm = laser_rear.Qy * laser_rear.field( time );
    cell->gp = laser_rear.Qz * laser_rear.field( time + laser_rear.shift); */
    cell->fm = laser_rear.field( time , 0 );
    cell->gp = laser_rear.field( time , 1 );
  }
  else {
    cell->fm = grid.rbuf->fm - pidt * cell->jy;
    cell->gp = grid.rbuf->gp - pidt * cell->jz;
  }

  cell->ey = cell->fp + cell->fm;   cell->bz = cell->fp - cell->fm;
  cell->ez = cell->gp + cell->gm;   cell->by = cell->gp - cell->gm;

  cell->ex -= 2*pidt * cell->jx;
}


//////////////////////////////////////////////////////////////////////////////////////////
//EOF