1 /*
2 Copyright (c) 1990 Massachusetts Institute of Technology, Cambridge, MA.
3 All rights reserved.
4 
5 This Agreement gives you, the LICENSEE, certain rights and obligations.
6 By using the software, you indicate that you have read, understood, and
7 will comply with the terms.
8 
9 Permission to use, copy and modify for internal, noncommercial purposes
10 is hereby granted.  Any distribution of this program or any part thereof
11 is strictly prohibited without prior written consent of M.I.T.
12 
13 Title to copyright to this software and to any associated documentation
14 shall at all times remain with M.I.T. and LICENSEE agrees to preserve
15 same.  LICENSEE agrees not to make any copies except for LICENSEE'S
16 internal noncommercial use, or to use separately any portion of this
17 software without prior written consent of M.I.T.  LICENSEE agrees to
18 place the appropriate copyright notice on any such copies.
19 
20 Nothing in this Agreement shall be construed as conferring rights to use
21 in advertising, publicity or otherwise any trademark or the name of
22 "Massachusetts Institute of Technology" or "M.I.T."
23 
24 M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  By
25 way of example, but not limitation, M.I.T. MAKES NO REPRESENTATIONS OR
26 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
27 THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS OR DOCUMENTATION WILL
28 NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
29 M.I.T. shall not be held liable for any liability nor for any direct,
30 indirect or consequential damages with respect to any claim by LICENSEE
31 or any third party on account of or arising from this Agreement or use
32 of this software.
33 */
34 
35 #include "mulGlobal.h"
36 
37 /*
38   converts the voltage vector entries corresponding to panels on dielectric
39      interfaces into electric field boundary condition checks:
40      eps_outer*E_outer - eps_inner*E_inner
41   this routine might be improved by fixing the way dummy, permittivity and h
42      information is stored (more arrays and less pointer chasing)
43   also - infinitesimally thin conductors on a dielectric i/f (surface type
44      BOTH) are not supported
45 */
compute_electric_fields(sys,chglist)46 void compute_electric_fields(sys, chglist)
47 ssystem *sys;
48 charge *chglist;
49 {
50   charge *cp, *dummy;
51   double h, flux_density, *panel_voltages;
52   surface *surf;
53 
54   /* for each dielectric panel, do two divided differences to get the */
55   /*    gradient of the potential in the normal and anti-normal directions */
56   /* store the divided difference where the real panel's voltage was */
57   /* zero the dummy panel voltage entries so that iterative loop will be OK */
58   /* - the zeros can be skipped in the iterative loop calculations */
59   panel_voltages = sys->p;
60   for(cp = chglist; cp != NULL; cp = cp->next) {
61     if(cp->dummy) continue;
62 
63     if((surf = cp->surf)->type == DIELEC) {
64       dummy = cp->pos_dummy;
65       /* area field is divided difference step h for dummy panels */
66       flux_density = surf->outer_perm *
67        (panel_voltages[dummy->index] - panel_voltages[cp->index])/dummy->area;
68 
69 #if DMPELE == ON
70       fprintf(stdout,
71 	      "Electric flux density evaluation at (%g %g %g), panel %d\n",
72 	      cp->x, cp->y, cp->z, cp->index);
73       fprintf(stdout, "  pos_dummy at (%g %g %g), potential = %g\n",
74 	      dummy->x, dummy->y, dummy->z, panel_voltages[dummy->index]);
75       fprintf(stdout, "  normal deriv on + side = %g(%g - %g)/%g = %g\n",
76 	      surf->outer_perm,
77 	      panel_voltages[dummy->index], panel_voltages[cp->index],
78 	      dummy->area, flux_density);
79 #endif
80 
81       panel_voltages[dummy->index] = 0.0;
82 
83       dummy = cp->neg_dummy;
84 
85 #if DMPELE == ON
86       fprintf(stdout, "  neg_dummy at (%g %g %g), potential = %g\n",
87 	      dummy->x, dummy->y, dummy->z, panel_voltages[dummy->index]);
88       fprintf(stdout, "  normal deriv on - side = %g(%g - %g)/%g = %g\n",
89 	      surf->inner_perm,
90 	      panel_voltages[cp->index], panel_voltages[dummy->index],
91 	      dummy->area, surf->inner_perm *
92        (panel_voltages[cp->index] - panel_voltages[dummy->index])/dummy->area);
93 #endif
94 
95       /* area field is divided difference step h for dummy panels */
96       flux_density -= (surf->inner_perm *
97        (panel_voltages[cp->index] - panel_voltages[dummy->index])/dummy->area);
98       panel_voltages[dummy->index] = 0.0;
99 
100       /* store the normal flux density difference */
101       panel_voltages[cp->index] = flux_density;
102 
103 #if DMPELE == ON
104       fprintf(stdout,
105 	      "  flux density difference (pos side - neg side) = %g\n",
106 	      flux_density);
107 #endif
108     }
109   }
110 }
111