/home66/gary/public_html/cloudy/c08_branch/source/parse_dlaw.cpp

Go to the documentation of this file.
00001 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
00002  * others.  For conditions of distribution and use see copyright notice in license.txt */
00003 /*ParseDLaw parse parameters on the dlaw command */
00004 #include "cddefines.h"
00005 #include "dense.h"
00006 #include "optimize.h"
00007 #include "abund.h"
00008 #include "input.h"
00009 #include "radius.h"
00010 #include "parse.h"
00011 
00012 void ParseDLaw(char *chCard )
00013 {
00014         char chCAP[5];
00015         bool lgEOL, 
00016           lgEnd;
00017         long int i, 
00018           j;
00019 
00020         DEBUG_ENTRY( "ParseDLaw()" );
00021 
00022         if( dense.gas_phase[ipHYDROGEN] > 0. )
00023         {
00024                 fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" );
00025                 cdEXIT(EXIT_FAILURE);
00026         }
00027 
00028         /* call fcn dense_fabden(RADIUS) which uses the ten parameters
00029          * N.B.; existing version of dense_fabden must be deleted
00030          * >>chng 96 nov 29, added table option */
00031         if( nMatch("TABL",chCard) )
00032         {
00033                 /* when called, read in densities from input stream */
00034                 strcpy( dense.chDenseLaw, "DLW2" );
00035                 if( nMatch("DEPT",chCard) )
00036                 {
00037                         dense.lgDLWDepth = true;
00038                 }
00039                 else
00040                 {
00041                         dense.lgDLWDepth = false;
00042                 }
00043 
00044                 input_readarray(chCard,&lgEnd);
00045                 i = 1;
00046                 dense.frad[0] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00047                 dense.fhden[0] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00048                 if( lgEOL )
00049                 {
00050                         fprintf( ioQQQ, " No pairs entered - can\'t interpolate.\n Sorry.\n" );
00051                         cdEXIT(EXIT_FAILURE);
00052                 }
00053 
00054                 dense.nvals = 2;
00055                 lgEnd = false;
00056 
00057                 /* read pairs of numbers until we find line starting with END */
00058                 /* >>chng 04 jan 27, loop to LIMTABDLAW from LIMTABD, as per
00059                  * var definitions, caught by Will Henney */
00060                 while( !lgEnd && dense.nvals < LIMTABDLAW )
00061                 {
00062                         input_readarray(chCard,&lgEnd);
00063                         if( !lgEnd )
00064                         {
00065                                 cap4(chCAP , chCard);
00066                                 if( strncmp(chCAP , "END" , 3 ) == 0 )
00067                                         lgEnd = true;
00068                         }
00069 
00070                         if( !lgEnd )
00071                         {
00072                                 i = 1;
00073                                 dense.frad[dense.nvals-1] = (realnum)FFmtRead(chCard
00074                                   ,&i,INPUT_LINE_LENGTH,&lgEOL);
00075                                 dense.fhden[dense.nvals-1] = (realnum)FFmtRead(chCard
00076                                   ,&i,INPUT_LINE_LENGTH,&lgEOL);
00077                                 dense.nvals += 1;
00078                         }
00079                 }
00080                 --dense.nvals;
00081 
00082                 for( i=1; i < dense.nvals; i++ )
00083                 {
00084                         /* the radius values are assumed to be strictly increasing */
00085                         if( dense.frad[i] <= dense.frad[i-1] )
00086                         {
00087                                 fprintf( ioQQQ, " density.in radii must be in increasing order\n" );
00088                                 cdEXIT(EXIT_FAILURE);
00089                         }
00090                 }
00091         }
00092         else
00093         {
00094                 /* this is usual case, call dense_fabden to get density */
00095                 i = 4;
00096                 for( j=0; j < 10; j++ )
00097                 {
00098                         dense.DensityLaw[j] = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00099                 }
00100 
00101                 /* set flag so we know which law to use later */
00102                 strcpy( dense.chDenseLaw, "DLW1" );
00103 
00104                 /* vary option */
00105                 if( optimize.lgVarOn )
00106                 {
00107                         /* NB - there are 5 = LIMEXT numbers on this line - if LIMEXT ever changes,
00108                          * chnage this too */
00109                         strcpy( optimize.chVarFmt[optimize.nparm], "DLAW %f %f %f %f %f " );
00110 
00111                         /* index for where to write */
00112                         optimize.nvfpnt[optimize.nparm] = input.nRead;
00113                         for( j=0; j<LIMEXT; ++j )
00114                         {
00115                                 optimize.vparm[j][optimize.nparm] = (realnum)dense.DensityLaw[j];
00116                         }
00117                         optimize.vincr[optimize.nparm] = 0.5;
00118                         optimize.nvarxt[optimize.nparm] = LIMEXT;
00119                         ++optimize.nparm;
00120                 }
00121         }
00122 
00123         /* set fake density to signal that density command was entered */
00124         /* real density will be set once all input commands have been read */
00125         /* this is necessary since density may depend on subsequent commands */
00126         dense.gas_phase[ipHYDROGEN] = 1.f;
00127 
00128         return;
00129 }

Generated on Mon Feb 16 12:01:25 2009 for cloudy by  doxygen 1.4.7