cloudy  trunk
 All Data Structures Namespaces 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-2022 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 "input.h"
8 #include "parser.h"
9 
10 void ParseDLaw(Parser &p)
11 {
12  long int j;
13 
14  DEBUG_ENTRY( "ParseDLaw()" );
15 
16  if( dense.gas_phase[ipHYDROGEN] > 0. )
17  {
18  fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" );
20  }
21 
22  /* call fcn dense_fabden(RADIUS) which uses the ten parameters
23  * N.B.; existing version of dense_fabden must be deleted
24  * >>chng 96 nov 29, added table option */
25  if( p.nMatch("TABL") )
26  {
27  /* when called, read in densities from input stream */
28  strcpy( dense.chDenseLaw, "DLW2" );
29 
30  p.readLaw(dense.DLW);
31  }
32  else if( p.nMatch("WIND") )
33  {
34  strcpy( dense.chDenseLaw, "DLW3" );
35  /* This sets up a steady-state "wind" profile parametrized as in Springmann (1994):
36  *
37  * v(r) = v_star + (v_inf - v_0) * sqrt( Beta1 x + (1-Beta1) x^Beta2 )
38  *
39  * A mass loss rate into 4pi sterradians Mdot then allows the density via continuity:
40  *
41  * n(r) = Mdot / ( 4Pi m_H * mu * r^2 * v(r) )
42  */
43 
44  /* The parameters must be specified in this order:
45  *
46  * Mdot, v_inf, Beta2, Beta1, v_0, v_star.
47  *
48  * Only the first three are required. The final three may be omitted right to left and
49  * take default values Beta1 = v_0 = v_star = 0. */
50 
51  for( j=0; j < 6; j++ )
52  {
53  dense.DensityLaw[j] = p.FFmtRead();
54  if( j <= 2 && p.lgEOL() )
55  p.NoNumb("density law element");
56  }
57  }
58  else
59  {
60  /* this is usual case, call dense_fabden to get density */
61  for( j=0; j < 10; j++ )
62  {
63  dense.DensityLaw[j] = p.FFmtRead();
64  if( j == 0 && p.lgEOL() )
65  p.NoNumb("density law element");
66  }
67 
68  /* set flag so we know which law to use later */
69  strcpy( dense.chDenseLaw, "DLW1" );
70 
71  /* vary option */
72  if( optimize.lgVarOn )
73  {
74  ostringstream oss;
75  oss << "DLW %f" << setprecision(7);
76  for( j=1; j < 10; j++ )
77  oss << " " << dense.DensityLaw[j];
78  strcpy( optimize.chVarFmt[optimize.nparm], oss.str().c_str() );
80 
81  /* index for where to write */
84  optimize.vincr[optimize.nparm] = 0.5f;
86  ++optimize.nparm;
87  }
88  }
89 
90  /* set fake density to signal that density command was entered */
91  /* real density will be set once all input commands have been read */
92  /* this is necessary since density may depend on subsequent commands */
94 
95  return;
96 }
bool nMatch(const char *chKey) const
Definition: parser.h:150
void SetGasPhaseDensity(const long nelem, const realnum density)
Definition: dense.cpp:106
double FFmtRead(void)
Definition: parser.cpp:472
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
void ParseDLaw(Parser &p)
Definition: parse_dlaw.cpp:10
Definition: parser.h:43
bool lgVarOn
Definition: optimize.h:207
t_dense dense
Definition: global.cpp:15
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
DepthTable DLW
Definition: dense.h:198
NORETURN void NoNumb(const char *chDesc) const
Definition: parser.cpp:345
t_optimize optimize
Definition: optimize.cpp:6
realnum vincr[LIMPAR]
Definition: optimize.h:195
realnum gas_phase[LIMELM]
Definition: dense.h:76
bool lgOptimizeAsLinear[LIMPAR]
Definition: optimize.h:184
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
double DensityLaw[10]
Definition: dense.h:191
void readLaw(DepthTable &table)
Definition: parser.cpp:976
const int ipHYDROGEN
Definition: cddefines.h:349
long int nvarxt[LIMPAR]
Definition: optimize.h:198