cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_fluc.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 /*ParseFluc parse the fluctuations command, which affects either density or abundances */
4 #include "cddefines.h"
5 #include "dense.h"
6 #include "parse.h"
7 
8 void ParseFluc(char *chCard )
9 {
10  bool lgEOL;
11  long int i;
12  double flmax,
13  flmin,
14  period,
15  temp;
16 
17  DEBUG_ENTRY( "ParseFluc()" );
18 
19  /* rapid density fluctuations
20  * first parameter is log of period, 2 is log den max, 3 log Nmin */
21  if( nMatch("ABUN",chCard) )
22  {
23  /* abundances varied, not density */
24  dense.lgDenFlucOn = false;
25  }
26  else
27  {
28  /* density is varied */
29  dense.lgDenFlucOn = true;
30  }
31 
32  /* optional keyword COLUMN makes sin over column density rather than radius */
33  if( nMatch("COLU",chCard) )
34  {
35  /* found key, not fluc over radius, over col den instead */
36  dense.lgDenFlucRadius = false;
37  }
38  else
39  {
40  /* no key, use default of radius */
41  dense.lgDenFlucRadius = true;
42  }
43 
44  i = 5;
45  /* 1st number log of period in centimeters */
46  period = pow(10.,FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL));
47  dense.flong = (realnum)(6.2831853/period);
48  temp = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
49 
50  /* check size of density - will we crash? */
51  if( temp > log10(FLT_MAX) || temp < log10(FLT_MIN) )
52  {
53  fprintf(ioQQQ,
54  " DISASTER - the log of the entered max hydrogen density is %.3f - too extreme for this processor.\n",
55  temp);
56  if( temp > 0. )
57  fprintf(ioQQQ,
58  " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n",
59  log10(FLT_MAX) );
60  else
61  fprintf(ioQQQ,
62  " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n",
63  log10(FLT_MIN) );
64  fprintf(ioQQQ," Sorry.\n" );
65  cdEXIT(EXIT_FAILURE);
66  }
67 
68  /* 2nd number log of max hydrogen density */
69  flmax = pow(10.,temp);
70 
71  temp = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
72 
73  /* check size of density - will we crash? */
74  if( temp > log10(FLT_MAX) || temp < log10(FLT_MIN) )
75  {
76  fprintf(ioQQQ,
77  " DISASTER - the log of the entered min hydrogen density is %.3f - too extreme for this processor.\n",
78  temp);
79  if( temp > 0. )
80  fprintf(ioQQQ,
81  " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n",
82  log10(FLT_MAX) );
83  else
84  fprintf(ioQQQ,
85  " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n",
86  log10(FLT_MIN) );
87  fprintf(ioQQQ," Sorry.\n" );
88  cdEXIT(EXIT_FAILURE);
89  }
90 
91  /* 3rd number log of min hydrogen density */
92  flmin = pow(10.,temp);
93 
94  if( flmax/flmin > 100. )
95  {
96  fprintf( ioQQQ, "This range of density probably will not work.\n" );
97  }
98  if( flmax > 1e15 )
99  {
100  fprintf( ioQQQ, "These parameters look funny to me. Please check Hazy.\n" );
101  }
102  if( lgEOL || (flmin > flmax) )
103  {
104  fprintf( ioQQQ, "There MUST be three numbers on this line.\n" );
105  fprintf( ioQQQ, "These must be the period(cm), max, min densities, all logs, in that order.\n" );
106  if( flmin > flmax )
107  fprintf( ioQQQ, "The max density must be greater or equal than the min density.\n" );
108  cdEXIT(EXIT_FAILURE);
109  }
110 
111  /* this is optional phase shift for the command */
112  dense.flcPhase = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
113 
114  /* FacAbunSav = (cfirst * COS( depth*flong+flcPhase ) + csecnd) */
115  dense.cfirst = (realnum)((flmax - flmin)/2.);
116  dense.csecnd = (realnum)((flmax + flmin)/2.);
117  /* these will be added together with the first mult by sin - which goes to
118  * -1 - must not have a negative density */
120  /* >>chng 96 jul 13 moved depset to SetAbundances fac
121  * if( lgDenFlucOn ) then
122  * this is a pressure law
123  * chCPres = 'SINE'
124  * else
125  * this is the metallicity of the gas
126  * do i=3,limelm
127  * depset(i) = flmax
128  * end do
129  * endif
130  *
131  * now get density if this is density option (not abundances) */
132  if( dense.lgDenFlucOn )
133  {
134  strcpy( dense.chDenseLaw, "SINE" );
135 
136  if( dense.gas_phase[ipHYDROGEN] > 0. )
137  {
138  fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" );
139  cdEXIT(EXIT_FAILURE);
140  }
141 
142  /* depth is zero for first zone */
144 
145  if( dense.gas_phase[ipHYDROGEN] <= 0. )
146  {
147  fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density must be > 0.\n" );
148  cdEXIT(EXIT_FAILURE);
149  }
150  }
151  return;
152 }

Generated for cloudy by doxygen 1.8.4