cloudy trunk
Loading...
Searching...
No Matches
parse_hden.cpp
Go to the documentation of this file.
1/* This file is part of Cloudy and is copyright (C)1978-2013 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#include "cosmology.h"
10
12{
13 DEBUG_ENTRY( "ParseHDEN()" );
14
15 if( dense.gas_phase[ipHYDROGEN] > 0. )
16 {
17 fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" );
19 }
20
21 /* log of hydrogen density */
23 if( p.lgEOL() )
24 {
25 fprintf( ioQQQ, " DISASTER The density MUST be entered with this command. STOP\n" );
27 }
28
29 /* check for further options */
30 if( ! p.nMatch("LINE") )
31 {
32 /* check size of density - will we crash? */
33 if( dense.gas_phase[ipHYDROGEN] > log10(FLT_MAX) ||
34 dense.gas_phase[ipHYDROGEN] < log10(FLT_MIN) )
35 {
36 fprintf(ioQQQ,
37 " DISASTER - the log of the entered hydrogen density is %.3f - too extreme for this processor.\n",
39 if( dense.gas_phase[ipHYDROGEN] > 0. )
40 fprintf(ioQQQ,
41 " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n",
42 log10(FLT_MAX) );
43 else
44 fprintf(ioQQQ,
45 " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n",
46 log10(FLT_MIN) );
47 fprintf(ioQQQ," Sorry.\n" );
48
50 }
51
53 }
54
56 {
57 fprintf( ioQQQ, "This density is too high. This version of Cloudy does not permit densities greater than %e cm-3.\n", MAX_DENSITY );
59 }
60
61 if( dense.gas_phase[ipHYDROGEN] <= 0. )
62 {
63 fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density must be > 0.\n" );
65 }
66
67 /* this is the linear initial density */
69
70 /* check if exponent entered */
72 /* this branch when exponent was entered - do something with it */
73 if( !p.lgEOL() )
74 {
75 /* not constant density
76 * some sort of power law density distribution */
77 if( p.nMatch("COLU") )
78 {
79 /* density will depend on column density to a power
80 * number entered is col den, convert to scale radius
81 * at this point HDEN is LOG10 of hydrogen density */
82 dense.rscale = (realnum)pow(10.,p.FFmtRead());
83 if( p.lgEOL() )
84 {
85 fprintf( ioQQQ, " The column density MUST be set if the col den option is to be used.\n" );
87 }
88 strcpy( dense.chDenseLaw, "POWC" );
89 }
90 else if( p.nMatch("DEPT") )
91 {
92 /* depth option, sets scale radius, log cm */
93 dense.rscale = (realnum)pow(10.,p.FFmtRead());
94 if( p.lgEOL() )
95 {
96 fprintf( ioQQQ, " The scale depth MUST be set if the depth option is to be used.\n" );
98 }
99 strcpy( dense.chDenseLaw, "POWD" );
100 }
101 else
102 {
103 /* radius option, will be relative to inner radius */
104 strcpy( dense.chDenseLaw, "POWR" );
105 }
106 }
107
108 /* vary option */
109 if( optimize.lgVarOn )
110 {
111 /* pointer to where to write */
115
116 /* these are varios options for density laws,
117 * first is constant density or pressre*/
118 if( strcmp(dense.chDenseLaw ,"CDEN") == 0 ||
119 strcmp(dense.chDenseLaw ,"CPRE") == 0 ||
120 strcmp(dense.chDenseLaw ,"WIND") == 0 ||
121 strcmp(dense.chDenseLaw ,"DYNA") == 0
122 )
123 {
124 strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f LOG" );
126 }
127
128 /* power law density distrution */
129 else if( strcmp(dense.chDenseLaw,"POWR") == 0 )
130 {
131 strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f LOG, power=%f" );
134 }
135
136 /* power law with density scale depending on column density */
137 else if( strcmp(dense.chDenseLaw,"POWC") == 0 )
138 {
139 strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f LOG, power=%f, column=%f" );
143 }
144
145 /* power law with density scale depending on depth */
146 else if( strcmp(dense.chDenseLaw,"POWD") == 0 )
147 {
148 strcpy( optimize.chVarFmt[optimize.nparm], "HDEN=%f LOG, power=%f, depth=%f" );
152 }
153
154 /* could not identify an option */
155 else
156 {
157 fprintf( ioQQQ, " Internal error in HDEN\n" );
159 }
160 ++optimize.nparm;
161 }
162 return;
163}
FILE * ioQQQ
Definition: cddefines.cpp:7
const double MAX_DENSITY
Definition: cddefines.h:269
#define EXIT_FAILURE
Definition: cddefines.h:140
#define cdEXIT(FAIL)
Definition: cddefines.h:434
float realnum
Definition: cddefines.h:103
const int ipHYDROGEN
Definition: cddefines.h:305
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:684
Definition: parser.h:32
double FFmtRead(void)
Definition: parser.cpp:353
bool nMatch(const char *chKey) const
Definition: parser.h:135
bool lgEOL(void) const
Definition: parser.h:98
t_dense dense
Definition: dense.cpp:24
t_input input
Definition: input.cpp:12
t_optimize optimize
Definition: optimize.cpp:5
void ParseHDEN(Parser &p)
Definition: parse_hden.cpp:11
realnum DensityPower
Definition: dense.h:239
char chDenseLaw[5]
Definition: dense.h:158
realnum rscale
Definition: dense.h:240
realnum gas_phase[LIMELM]
Definition: dense.h:71
void SetGasPhaseDensity(const long nelem, const realnum density)
Definition: dense.cpp:86
realnum den0
Definition: dense.h:241
long int nRead
Definition: input.h:49
long int nparm
Definition: optimize.h:201
realnum vincr[LIMPAR]
Definition: optimize.h:191
realnum vparm[LIMEXT][LIMPAR]
Definition: optimize.h:188
bool lgVarOn
Definition: optimize.h:203
long int nvarxt[LIMPAR]
Definition: optimize.h:194
char chVarFmt[LIMPAR][FILENAME_PATH_LENGTH_2]
Definition: optimize.h:263
long int nvfpnt[LIMPAR]
Definition: optimize.h:195