Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_2DPDEParam.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2014 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_2DPDEParam.C,v $
27 //
28 // Purpose : This class only contains the instance processParams
29 // function. This was a big enough, confusing enough,
30 // function, that I decided to give it its own file. Most
31 // of the functions that are called from here can be found
32 // in N_DEV_2DPDESetup.C.
33 //
34 // Special Notes :
35 //
36 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
37 //
38 // Creation Date : 07/15/03
39 //
40 // Revision Information:
41 // ---------------------
42 //
43 // Revision Number: $Revision: 1.57 $
44 //
45 // Revision Date : $Date: 2014/02/24 23:49:18 $
46 //
47 // Current Owner : $Author: tvrusso $
48 //-------------------------------------------------------------------------
49 
50 #include <Xyce_config.h>
51 
52 
53 // ---------- Standard Includes ----------
54 #ifdef Xyce_DEBUG_DEVICE
55 #include <iostream>
56 #endif
57 
58 
59 // ---------- Xyce Includes ----------
60 #include <N_DEV_2DPDE.h>
61 #include <N_DEV_PDE_2DMesh.h>
62 #include <N_DEV_SourceData.h>
63 #include <N_DEV_DeviceOptions.h>
64 
65 namespace Xyce {
66 namespace Device {
67 namespace TwoDPDE {
68 
69 //-----------------------------------------------------------------------------
70 // Function : Instance::processParams
71 //
72 // Purpose : This function processes the user-specified parameters.
73 // This includes setting up the mesh.
74 //
75 // Special Notes : There are three modes in which processParams can
76 // be called:
77 //
78 // 1) Initialization of the class, for a standard simulation.
79 //
80 // 2) perturbing away from the original as part of a sensitivity
81 // calculation, in order to obtain a numerical df/dp.
82 //
83 // 3) restoring the device to its normal, unperturbed state.
84 //
85 // Call (1) is obviously the most common, and happens at
86 // the beginning of any simulation. This call will have
87 // no parameter argument.
88 //
89 // Calls (2) and (3) only happen for sensitivity calculations,
90 // and they always come in pairs. Anytime a (2) style call
91 // happens, it should be followed shortly by a (3) call.
92 //
93 // Call (2) will have a parameter argument, specifying which
94 // param to perturb. Call (3) doesn't have a param argument,
95 // and for most devices is identical to a call (1). However,
96 // for the PDE case, it doesn't makes sense to reallocate all
97 // the mesh stuff, so it just restores old values of the mesh
98 // from a copy.
99 //
100 // Scope : public
101 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
102 // Creation Date : 6/03/02
103 //-----------------------------------------------------------------------------
105 {
106  bool bsuccess = true;
107 
108  return bsuccess;
109 }
110 
111 
112 //-----------------------------------------------------------------------------
113 // Function : Instance::processDopingParams
114 // Purpose :
115 // Special Notes :
116 // Scope : public
117 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
118 // Creation Date : 4/04/04
119 //-----------------------------------------------------------------------------
120 bool Instance::processDopingParams (Param & ndParam, std::string param)
121 {
122  ExtendedString tagES = ndParam.tag ();
123  tagES.toLower ();
124 
125  // Start of the new doping section:
126  //string tmpTag (tagES,0,3);
127  if (std::string(tagES,0,3) == "reg" && ndParam.given())
128  //if dope region param, continue:
129  {
130  // the new metadata doesn't have a limitation on the number of
131  // regions.
132 
133  // first find the "." character.
134  int periodLocation = 0;
135  bool foundPeriod = false;
136  for (int iloc=0;iloc<tagES.size();++iloc)
137  {
138  std::string singleChar(tagES,iloc,1);
139  if (singleChar == ".")
140  {
141  periodLocation = iloc;
142  foundPeriod = true;
143  break;
144  }
145  }
146  if (!foundPeriod)
147  {
148  std::string msg =
149  "::processDopingParams. The region specification needs a period\n";
150  N_ERH_ErrorMgr::report( N_ERH_ErrorMgr::DEV_FATAL_0,msg);
151  }
152 
153  std::string regionName(tagES,0,periodLocation);
154 
155 #ifdef Xyce_DEBUG_DEVICE
156  if (getDeviceOptions().debugLevel > 0)
157  {
158  Xyce::dout() << "tagES = "<< tagES;
159  Xyce::dout() << " regionName = "<< regionName;
160  Xyce::dout() << " param: " << ndParam.stringValue() << std::endl;
161  }
162 #endif
163 
164  if ( dopeInfoMap.find(regionName) == dopeInfoMap.end() )
165  {
166  dopeInfoMap[regionName] = new DopeInfo();
167  dopeInfoMap[regionName]->name = regionName;
168  }
169 
170  // The actual processing of the parameter is handled in the DopeInfo
171  // class.
172  dopeInfoMap[regionName]->processParam (ndParam, param, *this);
173 
174  }
175  // End of the new doping section.
176 
177  return true;
178 }
179 //-----------------------------------------------------------------------------
180 // Function : Instance::processElectrodeParams
181 // Purpose :
182 // Special Notes :
183 // Scope : public
184 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
185 // Creation Date : 6/18/04
186 //-----------------------------------------------------------------------------
188 {
189 
190  ExtendedString tagES = ndParam.tag ();
191  tagES.toLower ();
192 
193  if (std::string(tagES,0,4) == "node" && ndParam.given() )
194  {
195  int periodLocation = 5;
196 
197  // Now that we've determined that this is an electrode parameter,
198  // ( and not one of the older "legacy" parameters )
199  // check if an electrode with this name already exists in the
200  // map.
201 
202  // If so, just modify the existing electrode. If not, add it
203  // to the map, with a set of default params (created by the
204  // default constructor).
205  //
206  // get the name by searching for the ".", just like in the case for
207  // the region specification.
208  // the new metadata doesn't have a limitation on the number of
209  // nodes.
210 
211  // first find the "." character.
212  periodLocation = 0;
213  bool foundPeriod = false;
214  for (int iloc=0;iloc<tagES.size();++iloc)
215  {
216  std::string singleChar(tagES,iloc,1);
217  if (singleChar == ".")
218  {
219  periodLocation = iloc;
220  foundPeriod = true;
221  break;
222  }
223  }
224 
225  // if no period is found, then report an error.
226  // At this point, node1 and node1bc style specifications have
227  // already been trapped for.
228  if (!foundPeriod)
229  {
230  std::string msg =
231  "::processParams. The node specification needs a period\n";
232  N_ERH_ErrorMgr::report( N_ERH_ErrorMgr::DEV_FATAL_0,msg);
233  }
234 
235  std::string nodeName(tagES,0,periodLocation);
236 #ifdef Xyce_DEBUG_DEVICE
237  if (getDeviceOptions().debugLevel > 0)
238  {
239  Xyce::dout() << "tagES = "<< tagES << std::endl;
240  Xyce::dout() << "nodeName = "<< nodeName << std::endl;
241  }
242 #endif
243 
244  if ( electrodeMap.find(nodeName) == electrodeMap.end() )
245  {
246  PDE_2DElectrode * elPtr = new PDE_2DElectrode ();
247  elPtr->nodeName = nodeName;
248  electrodeMap[nodeName] = elPtr;
249  }
250 
251  // now do the actual processing of the param.
252  int tagSize = tagES.size();
253 
254  if (tagSize > periodLocation+1)
255  {
256  std::string tmpParam(tagES,periodLocation+1,tagSize);
257 
258  if (tmpParam == "name")
259  {
260  DeviceInterfaceNode dINode;
261  ExtendedString dIName = ndParam.stringValue();
262  dIName.toUpper ();
263 
264  dINode.eName = dIName;
265  dINode.nName = nodeName;
266  dINode.given = ndParam.given();
267  dINode.index = 0;
268 
269  if (dINode.given) ++numElectrodes;
270  if (dINode.given) dIVec.push_back(dINode);
271  }
272 
273  if (tmpParam == "bc")
274  {
275  ExtendedString nmName = ndParam.stringValue();
276  nmName.toUpper ();
277  if (nmName == "NEUMANN" ||
278  nmName == "MIXED" )
279  {
280  tmpBCmap[nodeName] = nmName;
281  Xyce::dout() << "found a neumann. name = " << tagES << std::endl;
282  }
283  }
284 
285  if (tmpParam == "side")
286  {
287  if (ndParam.given())
288  {
289  ExtendedString tmpstr = ndParam.stringValue();
290  tmpstr.toLower ();
291  electrodeMap[nodeName]->side = tmpstr;
292  electrodeMap[nodeName]->sideGiven = true;
293  }
294  }
295 
296  if (tmpParam == "start")
297  {
298  electrodeMap[nodeName]->start = ndParam.getImmutableValue<double>();
299  electrodeMap[nodeName]->startGiven = ndParam.given ();
300  }
301 
302  if (tmpParam == "end")
303  {
304  electrodeMap[nodeName]->end = ndParam.getImmutableValue<double>();
305  electrodeMap[nodeName]->endGiven = ndParam.given ();
306  }
307 
308  if (tmpParam == "material")
309  {
310  ExtendedString tmpName = ndParam.stringValue();
311  tmpName.toLower();
312  electrodeMap[nodeName]->material = tmpName;
313  electrodeMap[nodeName]->materialGiven = ndParam.given ();
314  }
315 
316  if (tmpParam == "oxidebndryflag")
317  {
318  if (ndParam.given() && ndParam.getImmutableValue<int>() == 1)
319  electrodeMap[nodeName]->oxideBndryFlag = true;
320  else
321  electrodeMap[nodeName]->oxideBndryFlag = false;
322  }
323 
324  if (tmpParam == "oxthick")
325  {
326  electrodeMap[nodeName]->oxthick = ndParam.getImmutableValue<double>();
327  }
328 
329  if (tmpParam == "oxcharge")
330  {
331  electrodeMap[nodeName]->oxcharge = ndParam.getImmutableValue<double>();
332  }
333  }
334  }
335 
336  return true;
337 }
338 
339 } // namespace TwoDPDE
340 } // namespace Device
341 } // namespace Xyce