cloudy  trunk
 All Data Structures Namespaces 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-2022 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 "parser.h"
9 
10 void ParseHDEN(Parser &p )
11 {
12  DEBUG_ENTRY( "ParseHDEN()" );
13 
14  if( dense.gas_phase[ipHYDROGEN] > 0. )
15  {
16  fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" );
18  }
19 
20  /* log of hydrogen density */
22  if( p.lgEOL() )
23  {
24  fprintf( ioQQQ, " DISASTER The density MUST be entered with this command. STOP\n" );
26  }
27 
28  /* check for further options */
29  if( ! p.nMatch("LINE") )
30  {
31  /* check size of density - will we crash? */
32  if( dense.gas_phase[ipHYDROGEN] > log10(FLT_MAX) ||
33  dense.gas_phase[ipHYDROGEN] < log10(FLT_MIN) )
34  {
35  fprintf(ioQQQ,
36  " DISASTER - the log of the entered hydrogen density is %.3f - too extreme for this processor.\n",
38  if( dense.gas_phase[ipHYDROGEN] > 0. )
39  fprintf(ioQQQ,
40  " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n",
41  log10(FLT_MAX) );
42  else
43  fprintf(ioQQQ,
44  " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n",
45  log10(FLT_MIN) );
46  fprintf(ioQQQ," Sorry.\n" );
47 
49  }
50 
52  }
53 
55  {
56  fprintf( ioQQQ, "This density is too high. This version of Cloudy does not permit densities greater than %e cm-3.\n", MAX_DENSITY );
58  }
59 
60  if( dense.gas_phase[ipHYDROGEN] <= 0. )
61  {
62  fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density must be > 0.\n" );
64  }
65 
66  /* this is the linear initial density */
68 
69  /* check if exponent entered */
71  /* this branch when exponent was entered - do something with it */
72  if( !p.lgEOL() )
73  {
74  /* not constant density
75  * some sort of power law density distribution */
76  if( p.nMatch("COLU") )
77  {
78  /* density will depend on column density to a power
79  * number entered is col den, convert to scale radius
80  * at this point HDEN is LOG10 of hydrogen density */
82  if( p.lgEOL() )
83  {
84  fprintf( ioQQQ, " The column density MUST be set if the col den option is to be used.\n" );
86  }
87  strcpy( dense.chDenseLaw, "POWC" );
88  }
89  else if( p.nMatch("DEPT") )
90  {
91  /* depth option, sets scale radius, log cm */
93  if( p.lgEOL() )
94  {
95  fprintf( ioQQQ, " The scale depth MUST be set if the depth option is to be used.\n" );
97  }
98  strcpy( dense.chDenseLaw, "POWD" );
99  }
100  else
101  {
102  /* radius option, will be relative to inner radius */
103  strcpy( dense.chDenseLaw, "POWR" );
104  }
105  }
106 
107  /* vary option */
108  if( optimize.lgVarOn )
109  {
110  /* pointer to where to write */
114 
115  /* these are varios options for density laws,
116  * first is constant density or pressre*/
117  if( strcmp(dense.chDenseLaw ,"CDEN") == 0 ||
118  strcmp(dense.chDenseLaw ,"CPRE") == 0 ||
119  strcmp(dense.chDenseLaw ,"WIND") == 0 ||
120  strcmp(dense.chDenseLaw ,"DYNA") == 0
121  )
122  {
123  strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f LOG" );
125  }
126 
127  /* power law density distrution */
128  else if( strcmp(dense.chDenseLaw,"POWR") == 0 )
129  {
130  strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f LOG, power=%f" );
133  }
134 
135  /* power law with density scale depending on column density */
136  else if( strcmp(dense.chDenseLaw,"POWC") == 0 )
137  {
138  strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f LOG, power=%f, column=%f" );
142  }
143 
144  /* power law with density scale depending on depth */
145  else if( strcmp(dense.chDenseLaw,"POWD") == 0 )
146  {
147  strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f LOG, power=%f, depth=%f" );
151  }
152 
153  /* could not identify an option */
154  else
155  {
156  fprintf( ioQQQ, " Internal error in HDEN\n" );
158  }
159  ++optimize.nparm;
160  }
161  return;
162 }
realnum den0
Definition: dense.h:252
bool nMatch(const char *chKey) const
Definition: parser.h:150
void ParseHDEN(Parser &p)
Definition: parse_hden.cpp:10
void SetGasPhaseDensity(const long nelem, const realnum density)
Definition: dense.cpp:106
realnum DensityPower
Definition: dense.h:250
double FFmtRead(void)
Definition: parser.cpp:472
double exp10(double x)
Definition: cddefines.h:1368
t_input input
Definition: input.cpp:12
long int nvfpnt[LIMPAR]
Definition: optimize.h:198
long int nRead
Definition: input.h:105
char chVarFmt[LIMPAR][FILENAME_PATH_LENGTH_2]
Definition: optimize.h:267
FILE * ioQQQ
Definition: cddefines.cpp:7
realnum vparm[LIMEXT][LIMPAR]
Definition: optimize.h:192
Definition: parser.h:43
bool lgVarOn
Definition: optimize.h:207
t_dense dense
Definition: global.cpp:15
const double MAX_DENSITY
Definition: cddefines.h:319
long int nparm
Definition: optimize.h:204
float realnum
Definition: cddefines.h:124
#define EXIT_FAILURE
Definition: cddefines.h:168
#define cdEXIT(FAIL)
Definition: cddefines.h:482
t_optimize optimize
Definition: optimize.cpp:6
realnum vincr[LIMPAR]
Definition: optimize.h:195
realnum gas_phase[LIMELM]
Definition: dense.h:76
realnum rscale
Definition: dense.h:251
char chDenseLaw[5]
Definition: dense.h:176
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
bool lgEOL(void) const
Definition: parser.h:113
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
const int ipHYDROGEN
Definition: cddefines.h:349
long int nvarxt[LIMPAR]
Definition: optimize.h:198