cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_hden.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 /*ParseHDEN parse the hden command */
4 #include "cddefines.h"
5 #include "input.h"
6 #include "dense.h"
7 #include "optimize.h"
8 #include "parse.h"
9 
10 void ParseHDEN(char *chCard )
11 {
12  bool lgEOL;
13  long int i;
14 
15  DEBUG_ENTRY( "ParseHDEN()" );
16 
17  if( dense.gas_phase[ipHYDROGEN] > 0. )
18  {
19  fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" );
20  cdEXIT(EXIT_FAILURE);
21  }
22 
23  /* log of hydrogen density */
24  i = 5;
26  if( lgEOL )
27  {
28  fprintf( ioQQQ, " DISASTER The density MUST be entered with this command. STOP\n" );
29  cdEXIT(EXIT_FAILURE);
30  }
31 
32  /* check for further options */
33  if( ! nMatch("LINE",chCard) )
34  {
35  /* check size of density - will we crash? */
36  if( dense.gas_phase[ipHYDROGEN] > log10(FLT_MAX) ||
37  dense.gas_phase[ipHYDROGEN] < log10(FLT_MIN) )
38  {
39  fprintf(ioQQQ,
40  " DISASTER - the log of the entered hydrogen density is %.3f - too extreme for this processor.\n",
42  if( dense.gas_phase[ipHYDROGEN] > 0. )
43  fprintf(ioQQQ,
44  " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n",
45  log10(FLT_MAX) );
46  else
47  fprintf(ioQQQ,
48  " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n",
49  log10(FLT_MIN) );
50  fprintf(ioQQQ," Sorry.\n" );
51 
52  cdEXIT(EXIT_FAILURE);
53  }
54 
56  }
57 
58  if( dense.gas_phase[ipHYDROGEN] <= 0. )
59  {
60  fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density must be > 0.\n" );
61  cdEXIT(EXIT_FAILURE);
62  }
63 
64  /* this is the linear initial density */
66 
67  /* check if exponent entered */
69  /* this branch when exponent was entered - do something with it */
70  if( !lgEOL )
71  {
72  /* not constant density
73  * some sort of power law density distribution */
74  if( nMatch("COLU",chCard) )
75  {
76  /* density will depend on column density to a power
77  * number entered is col den, convert to scale radius
78  * at this point HDEN is LOG10 of hydrogen density */
79  dense.rscale = (realnum)pow(10.,FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL));
80  if( lgEOL )
81  {
82  fprintf( ioQQQ, " The column density MUST be set if the col den option is to be used.\n" );
83  cdEXIT(EXIT_FAILURE);
84  }
85  strcpy( dense.chDenseLaw, "POWC" );
86  }
87  else if( nMatch("DEPT",chCard) )
88  {
89  /* depth option, sets scale radius, log cm */
90  dense.rscale = (realnum)pow(10.,FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL));
91  if( lgEOL )
92  {
93  fprintf( ioQQQ, " The scale depth MUST be set if the depth option is to be used.\n" );
94  cdEXIT(EXIT_FAILURE);
95  }
96  strcpy( dense.chDenseLaw, "POWD" );
97  }
98  else
99  {
100  /* radius option, will be relative to inner radius */
101  strcpy( dense.chDenseLaw, "POWR" );
102  }
103  }
104 
105  /* vary option */
106  if( optimize.lgVarOn )
107  {
108  /* pointer to where to write */
112 
113  /* these are varios options for density laws,
114  * first is constant density or pressre*/
115  if( strcmp(dense.chDenseLaw ,"CDEN") == 0 ||
116  strcmp(dense.chDenseLaw ,"CPRE") == 0 )
117  {
118  strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f" );
120  }
121 
122  /* power law density distrution */
123  else if( strcmp(dense.chDenseLaw,"POWR") == 0 )
124  {
125  strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f, power=%f" );
128  }
129 
130  /* power law with density scale depending on column density */
131  else if( strcmp(dense.chDenseLaw,"POWC") == 0 )
132  {
133  strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f, power=%f, column=%f" );
137  }
138 
139  /* power law with density scale depending on depth */
140  else if( strcmp(dense.chDenseLaw,"POWD") == 0 )
141  {
142  strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f, power=%f, depth=%f" );
146  }
147 
148  /* could not idensity an option */
149  else
150  {
151  fprintf( ioQQQ, " Internal error in HDEN\n" );
152  cdEXIT(EXIT_FAILURE);
153  }
154  ++optimize.nparm;
155  }
156  return;
157 }

Generated for cloudy by doxygen 1.8.4