cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_dlaw.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*ParseDLaw parse parameters on the dlaw command */
4 #include "cddefines.h"
5 #include "dense.h"
6 #include "optimize.h"
7 #include "abund.h"
8 #include "input.h"
9 #include "radius.h"
10 #include "parse.h"
11 
12 void ParseDLaw(char *chCard )
13 {
14  char chCAP[5];
15  bool lgEOL,
16  lgEnd;
17  long int i,
18  j;
19 
20  DEBUG_ENTRY( "ParseDLaw()" );
21 
22  if( dense.gas_phase[ipHYDROGEN] > 0. )
23  {
24  fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" );
25  cdEXIT(EXIT_FAILURE);
26  }
27 
28  /* call fcn dense_fabden(RADIUS) which uses the ten parameters
29  * N.B.; existing version of dense_fabden must be deleted
30  * >>chng 96 nov 29, added table option */
31  if( nMatch("TABL",chCard) )
32  {
33  /* when called, read in densities from input stream */
34  strcpy( dense.chDenseLaw, "DLW2" );
35  if( nMatch("DEPT",chCard) )
36  {
37  dense.lgDLWDepth = true;
38  }
39  else
40  {
41  dense.lgDLWDepth = false;
42  }
43 
44  input_readarray(chCard,&lgEnd);
45  i = 1;
46  dense.frad[0] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
47  dense.fhden[0] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
48  if( lgEOL )
49  {
50  fprintf( ioQQQ, " No pairs entered - can\'t interpolate.\n Sorry.\n" );
51  cdEXIT(EXIT_FAILURE);
52  }
53 
54  dense.nvals = 2;
55  lgEnd = false;
56 
57  /* read pairs of numbers until we find line starting with END */
58  /* >>chng 04 jan 27, loop to LIMTABDLAW from LIMTABD, as per
59  * var definitions, caught by Will Henney */
60  while( !lgEnd && dense.nvals < LIMTABDLAW )
61  {
62  input_readarray(chCard,&lgEnd);
63  if( !lgEnd )
64  {
65  cap4(chCAP , chCard);
66  if( strncmp(chCAP , "END" , 3 ) == 0 )
67  lgEnd = true;
68  }
69 
70  if( !lgEnd )
71  {
72  i = 1;
73  dense.frad[dense.nvals-1] = (realnum)FFmtRead(chCard
74  ,&i,INPUT_LINE_LENGTH,&lgEOL);
75  dense.fhden[dense.nvals-1] = (realnum)FFmtRead(chCard
76  ,&i,INPUT_LINE_LENGTH,&lgEOL);
77  dense.nvals += 1;
78  }
79  }
80  --dense.nvals;
81 
82  for( i=1; i < dense.nvals; i++ )
83  {
84  /* the radius values are assumed to be strictly increasing */
85  if( dense.frad[i] <= dense.frad[i-1] )
86  {
87  fprintf( ioQQQ, " density.in radii must be in increasing order\n" );
88  cdEXIT(EXIT_FAILURE);
89  }
90  }
91  }
92  else
93  {
94  /* this is usual case, call dense_fabden to get density */
95  i = 4;
96  for( j=0; j < 10; j++ )
97  {
98  dense.DensityLaw[j] = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
99  }
100 
101  /* set flag so we know which law to use later */
102  strcpy( dense.chDenseLaw, "DLW1" );
103 
104  /* vary option */
105  if( optimize.lgVarOn )
106  {
107  /* NB - there are 5 = LIMEXT numbers on this line - if LIMEXT ever changes,
108  * chnage this too */
109  strcpy( optimize.chVarFmt[optimize.nparm], "DLAW %f %f %f %f %f " );
110 
111  /* index for where to write */
113  for( j=0; j<LIMEXT; ++j )
114  {
116  }
117  optimize.vincr[optimize.nparm] = 0.5;
119  ++optimize.nparm;
120  }
121  }
122 
123  /* set fake density to signal that density command was entered */
124  /* real density will be set once all input commands have been read */
125  /* this is necessary since density may depend on subsequent commands */
126  dense.gas_phase[ipHYDROGEN] = 1.f;
127 
128  return;
129 }

Generated for cloudy by doxygen 1.8.1.2