cloudy trunk
Loading...
Searching...
No Matches
cddrive.cpp File Reference
#include "cddefines.h"
#include "trace.h"
#include "conv.h"
#include "init.h"
#include "lines.h"
#include "pressure.h"
#include "prt.h"
#include "colden.h"
#include "dense.h"
#include "radius.h"
#include "struc.h"
#include "mole.h"
#include "elementnames.h"
#include "mean.h"
#include "phycon.h"
#include "called.h"
#include "parse.h"
#include "input.h"
#include "taulines.h"
#include "version.h"
#include "thermal.h"
#include "optimize.h"
#include "grid.h"
#include "timesc.h"
#include "cloudy.h"
#include "warnings.h"
#include "lines_service.h"
#include "cddrive.h"
#include "iso.h"
#include "save.h"
#include "noexec.h"
#include <sys/time.h>
#include <sys/resource.h>
Include dependency graph for cddrive.cpp:

Go to the source code of this file.

Functions

int cdDrive ()
void cdPrtWL (FILE *io, realnum wl)
void cdReasonGeo (FILE *ioOUT)
void cdWarnings (FILE *ioPNT)
void cdCautions (FILE *ioOUT)
void cdTimescales (double *TTherm, double *THRecom, double *TH2)
void cdSurprises (FILE *ioOUT)
void cdNotes (FILE *ioOUT)
double cdCooling_last ()
void cdVersion (char chString[])
void cdDate (char chString[])
double cdHeating_last ()
double cdEDEN_last ()
void cdNoExec ()
STATIC void cdClock (struct timeval *clock_dat)
void cdSetExecTime ()
double cdExecTime ()
void cdPrintCommands (FILE *ioOUT)
long int cdEmis (char *chLabel, realnum wavelength, double *emiss)
long int cdEmis (char *chLabel, realnum wavelength, double *emiss, bool lgEmergent)
void cdEmis_ip (long int ipLine, double *emiss, bool lgEmergent)
int cdColm (const char *chLabel, long int ion, double *theocl)
void cdErrors (FILE *ioOUT)
void cdDepth_depth (double cdDepth[])
void cdPressure_depth (double TotalPressure[], double GasPressure[], double RadiationPressure[])
void cdPressure_last (double *PresTotal, double *PresGas, double *PresRad)
long int cdnZone ()
double cdTemp_last ()
int cdIonFrac (const char *chLabel, long int IonStage, double *fracin, const char *chWeight, bool lgDensity)
long debugLine (realnum wavelength)
long int cdLine (const char *chLabel, realnum wavelength, double *relint, double *absint)
long int cdLine (const char *chLabel, realnum wavelength, double *relint, double *absint, int LineType)
void cdLine_ip (long int ipLine, double *relint, double *absint)
void cdLine_ip (long int ipLine, double *relint, double *absint, int LineType)
void cdNwcns (bool *lgAbort_ret, long int *NumberWarnings, long int *NumberCautions, long int *NumberNotes, long int *NumberSurprises, long int *NumberTempFailures, long int *NumberPresFailures, long int *NumberIonFailures, long int *NumberNeFailures)
void cdOutput (const char *filename, const char *mode)
void cdInput (const char *filename, const char *mode)
void cdTalk (bool lgTOn)
double cdB21cm ()
int cdTemp (const char *chLabel, long int IonStage, double *TeMean, const char *chWeight)
int cdRead (const char *chInputLine)
void cdClosePunchFiles ()

Variables

static bool lgCalled =false
static struct timeval before

Function Documentation

◆ cdB21cm()

double cdB21cm ( )

cdB21cm returns B as measured by 21 cm assumes tangled field weighted by n(H0)/T

Definition at line 1561 of file cddrive.cpp.

References DEBUG_ENTRY, mean, and SMALLFLOAT.

Referenced by PrtFinal().

◆ cdCautions()

void cdCautions ( FILE * ioOUT)

produces list of cautions

Definition at line 226 of file cddrive.cpp.

References DEBUG_ENTRY, and warnings.

Referenced by cdErrors(), PrtComment(), SaveLineIntensity(), SaveResults(), and ShowMe().

◆ cdClock()

STATIC void cdClock ( struct timeval * clock_dat)

Definition at line 444 of file cddrive.cpp.

References cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, ioQQQ, and STATIC.

Referenced by cdExecTime(), and cdSetExecTime().

◆ cdClosePunchFiles()

void cdClosePunchFiles ( )

wrapper to close all save files

Definition at line 1953 of file cddrive.cpp.

References CloseSaveFiles(), and DEBUG_ENTRY.

Here is the call graph for this function:

◆ cdColm()

int cdColm ( const char * chLabel,
long int ion,
double * theocl )

◆ cdCooling_last()

double cdCooling_last ( )

cdCooling_last The returns the total cooling (erg cm^-3 s^-1) for the last computed zone

Definition at line 333 of file cddrive.cpp.

References thermal.

◆ cdDate()

void cdDate ( char chString[])

cdDate The argument is a string with at least 8 char that will receive a null terminated string with the date of the current version of the code.

Definition at line 361 of file cddrive.cpp.

References Singleton< t_version >::Inst().

Here is the call graph for this function:

◆ cdDepth_depth()

void cdDepth_depth ( double cdDepth[])

returns depth structure of previous model

Parameters
cdDepth[]

Definition at line 976 of file cddrive.cpp.

References DEBUG_ENTRY, nzone, and struc.

◆ cdDrive()

int cdDrive ( )

cdDrive This command actually computes a model. It returns 0 if the calculation was successful, and 1 if an error condition was encountered

Definition at line 77 of file cddrive.cpp.

References cdEXIT, cloudy(), DEBUG_ENTRY, EXIT_FAILURE, grid_do(), InitCoreload(), input, ioQQQ, lgAbort, lgcdInitCalled, optimize, and trace.

Referenced by cdMain().

Here is the call graph for this function:

◆ cdEDEN_last()

double cdEDEN_last ( )

cdEDEN_last return electron density of last zone

Definition at line 390 of file cddrive.cpp.

References dense.

◆ cdEmis() [1/2]

long int cdEmis ( char * chLabel,
realnum wavelength,
double * emiss )

cdEmis This routine finds the local emissivity for any line. The first argument is the 4 character (null terminated) label as it appears in the standard output. The second argument is float wavelength as it appears in the standard output. The emissivity (erg /cm^3 /s) is returned as the last parameter. cdEms returns the index of the line in the stack if it was found, the negative of the total number of lines in the stack if it could not find the line

Parameters
*chLabel4 char null terminated string label
wavelengthline wavelength
*emissthe vol emissivity of this line in last computed zone
lgEmergentintrinsic or emergent emissivities
Returns
return value will be index of line within stack

Definition at line 533 of file cddrive.cpp.

References cdEmis(), DEBUG_ENTRY, and wavelength.

Referenced by cdEmis(), and save_line().

Here is the call graph for this function:

◆ cdEmis() [2/2]

long int cdEmis ( char * chLabel,
realnum wavelength,
double * emiss,
bool lgEmergent )

Definition at line 550 of file cddrive.cpp.

References cap4(), caps(), DEBUG_ENTRY, INPUT_LINE_LENGTH, LineSave, LineSv, wavelength, and WavlenErrorGet().

Here is the call graph for this function:

◆ cdEmis_ip()

void cdEmis_ip ( long int ipLine,
double * emiss,
bool lgEmergent )

cdEms_ip obtain the local emissivity for a line with known index

Parameters
ipLineindex of the line in the stack
*emissthe vol emissivity of this line in last computed zone
lgEmergentintrinsic or emergent emissivities

Definition at line 613 of file cddrive.cpp.

References ASSERT, DEBUG_ENTRY, ipLine, LineSave, and LineSv.

Referenced by save_line().

◆ cdErrors()

void cdErrors ( FILE * ioOUT)

cdErrors After the calculation is completed, a summary of all error messages can be be generated by calling this routine. The argument is the output file

Parameters
[out]*ioOUToutput file

Definition at line 910 of file cddrive.cpp.

References cdCautions(), cdNwcns(), cdWarnings(), DEBUG_ENTRY, and input.

Here is the call graph for this function:

◆ cdExecTime()

double cdExecTime ( )

cdExecTime returns the elapsed time cpu time (sec) that has elapsed since cdInit called cdSetExecTime.

Definition at line 481 of file cddrive.cpp.

References before, cdClock(), cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, ioQQQ, and lgCalled.

Referenced by cdMain(), PrtFinal(), and SaveDo().

Here is the call graph for this function:

◆ cdHeating_last()

double cdHeating_last ( )

cdHeating_last returns the total heating (erg cm^-3 s^-1) for the last computed zone

Definition at line 376 of file cddrive.cpp.

References thermal.

◆ cdInput()

void cdInput ( const char * filename = "",
const char * mode = "r" )

cdInput This tells the code where to get input. The arguments are as for the stdio.h fopen call, but the resulting file pointer is checked for validity. All further input will come from this file.
If filename = "", input is switched to stdin (and mode is ignored). If this routine is not called then all input will come from stdin, the standard c input

Definition at line 1530 of file cddrive.cpp.

References AS_LOCAL_ONLY, DEBUG_ENTRY, ioStdin, and open_data().

Referenced by cdMain(), and cdPrepareExit().

Here is the call graph for this function:

◆ cdIonFrac()

int cdIonFrac ( const char * chLabel,
long int IonStage,
double * fracin,
const char * chWeight,
bool lgDensity )
 * cdIonFrac
 * This returns the ionization fraction for any element included in the calculation. 
 * The first parameter is 4 char null terminated string giving the first 4 letters of
 * element name as spelled by Cloudy.  
 * The second parameter is an integer giving the ionization stage, 
 * 1 for atom, 2 for first ion, etc.
 * The third parameter returns the predicted ionization fraction of that ion stage.
 * The last parameter is an 8 character + null string that says either "volume" or "radius",
 * to specify whether the average should be weighted by volume or radius.
 * The return value is 0 if the routine could find the species and
 * non-zero if it failed to find the element 
Parameters
*chLabelfour char string, null terminated, giving the element name
IonStageIonStage is ionization stage, 1 for atom, up to N+1 where N is atomic number
*fracinwill be fractional ionization
*chWeighthow to weight the average, must be "VOLUME" or "RADIUS"
lgDensityif true then weighting also has electron density, if false then only volume or radius

Definition at line 1072 of file cddrive.cpp.

References caps(), DEBUG_ENTRY, elementnames, INPUT_LINE_LENGTH, ioQQQ, ipHYDROGEN, LIMELM, and mean.

Referenced by DynaPunchTimeDep(), lgCheckMonitors(), and save_average().

Here is the call graph for this function:

◆ cdLine() [1/2]

long int cdLine ( const char * chLabel,
realnum wavelength,
double * relint,
double * absint )

cdLine This routine finds the predicted intensity of any line in the standard output.

Parameters
*chLabel1st parameter is the 4-char label + null terminated label, as it appears in the output.
wavelength2nd parameter is the float wavelength in Angstroms, not how it appears in printout. The first four digits must agree with the number in the printout, but the units must be Angstroms. 3rd parameter is the predicted intensity relative to the normalization line. 4th par is the log of the predicted luminosity or intensity of the line (ergs).
*relint5th is pointer to relative intensity, a double that is returned
*absint6th is pointer to log of absolute intensity
lEmergent- emergent or intrinsic intensity
Returns
return value: The routine returns an index (>0) of the array element within stack if it finds the line, It returns the negative of the total number of lines if it could not find the line. (this is a debugging aid) note that this returns a long int since there are LOTS of lines this also IS NOT the standard C convention for success or failure

Definition at line 1228 of file cddrive.cpp.

References cdLine(), DEBUG_ENTRY, and wavelength.

Referenced by cdLine(), ConvIterCheck(), Drive_cdLine(), FeIISaveLines(), IterStart(), lgCheckMonitors(), lines(), lines_table(), optimize_func(), PrtComment(), PrtFinal(), PrtLineSum(), save_line(), and SaveDo().

Here is the call graph for this function:

◆ cdLine() [2/2]

long int cdLine ( const char * chLabel,
realnum wavelength,
double * relint,
double * absint,
int LineType )

Definition at line 1241 of file cddrive.cpp.

References ASSERT, BIGFLOAT, cap4(), DEBUG_ENTRY, fp_equal(), ioQQQ, LineSave, LineSv, prt_wl(), radius, TotalInsanity(), wavelength, and WavlenErrorGet().

Here is the call graph for this function:

◆ cdLine_ip() [1/2]

void cdLine_ip ( long int ipLine,
double * relint,
double * absint )

Definition at line 1414 of file cddrive.cpp.

References cdLine_ip(), DEBUG_ENTRY, and ipLine.

Referenced by cdLine_ip(), lgCheckMonitors(), and PrtLineSum().

Here is the call graph for this function:

◆ cdLine_ip() [2/2]

void cdLine_ip ( long int ipLine,
double * relint,
double * absint,
int LineType )

cdLine_ip get the predicted line intensity, using index for line in stack

Parameters
ipLine
*relintlinear intensity relative to normalization line
*absintlog of luminosity or intensity of line
lgEmergent- intrinsic or emergent intensity

Definition at line 1424 of file cddrive.cpp.

References ASSERT, DEBUG_ENTRY, ioQQQ, ipLine, LineSave, LineSv, and radius.

◆ cdNoExec()

void cdNoExec ( )

cdNoExec This provides option to have the code prepare the initial conditions for a model, but not actually try to compute the model. I use this when setting up a large grid so that I can quickly run through the full grid as a check that the commands are entered properly and the parameters I am going to vary do so properly. The command is then commented out when the grid is properly set up.

Definition at line 404 of file cddrive.cpp.

References DEBUG_ENTRY, and noexec.

◆ cdNotes()

void cdNotes ( FILE * ioOUT)

produces list of Notes

Definition at line 309 of file cddrive.cpp.

References DEBUG_ENTRY, and warnings.

Referenced by PrtComment().

◆ cdNwcns()

void cdNwcns ( bool * lgAbort,
long int * NumberWarnings,
long int * NumberCautions,
long int * NumberNotes,
long int * NumberSurprises,
long int * NumberTempFailures,
long int * NumberPresFailures,
long int * NumberIonFailures,
long int * NumberNeFailures )

cdNwcns This command returns the number of warnings, cautions, notes, surprises, assorted types of failures found the last computed model

Parameters
*lgAbortabort status, if non-zero then big problems happened
*NumberWarningsthe number of warnings
*NumberCautionsthe number of cautions
*NumberNotesthe number of notes
*NumberSurprisesthe number of surprises
*NumberTempFailuresthe number of temperature convergence failures
*NumberPresFailuresthe number of pressure convergence failures
*NumberIonFailuresthe number of ionization convergence failures
*NumberNeFailuresthe number of electron density convergence failures

Definition at line 1481 of file cddrive.cpp.

References conv, DEBUG_ENTRY, lgAbort, and warnings.

Referenced by cdErrors(), cdMain(), and PrtComment().

◆ cdnZone()

long int cdnZone ( )

cdnZone returns number of zones

Definition at line 1049 of file cddrive.cpp.

References nzone.

◆ cdOutput()

void cdOutput ( const char * filename = "",
const char * mode = "w" )

cdOutput This tells the code where to send output. The arguments are as for the stdio.h fopen call, but the resulting file pointer is checked for validity. All further log output will go to this file.
If filename = "", output is switched to stdout (and mode is ignored). If this routine is not called then all output will go to stdout, the standard c output

Definition at line 1517 of file cddrive.cpp.

References AS_LOCAL_ONLY, DEBUG_ENTRY, ioQQQ, open_data(), and save.

Referenced by cdMain(), and cdPrepareExit().

Here is the call graph for this function:

◆ cdPressure_depth()

void cdPressure_depth ( double TotalPressure[],
double GasPressure[],
double RadiationPressure[] )

cdPressure_depth This returns the pressure and its constituents for the last iteration. space was allocated in the calling routine for the vectors - before calling this, cdnZone should have been called to get the number of zones, then space allocated for the arrays

Parameters
TotalPressure[]total pressure, all forms
GasPressure[]gas pressure
RadiationPressure[]radiation pressure

Definition at line 1001 of file cddrive.cpp.

References DEBUG_ENTRY, nzone, and struc.

◆ cdPressure_last()

void cdPressure_last ( double * TotalPressure,
double * GasPressure,
double * RadiationPressure )

cdPressure_last This returns the pressure and its constituents for the last computed zone.

Parameters
*TotalPressuretotal pressure, all forms
*GasPressuregas pressure
*RadiationPressureradiation pressure

Definition at line 1028 of file cddrive.cpp.

References DEBUG_ENTRY, and pressure.

◆ cdPrintCommands()

void cdPrintCommands ( FILE * ioOUT)

cdPrintCommands( FILE *) This routine prints all input commands into file whose handle is the argument

Parameters
*ioOUT[out] output file handle

Definition at line 513 of file cddrive.cpp.

References input.

Referenced by ShowMe().

◆ cdPrtWL()

void cdPrtWL ( FILE * io,
realnum wl )

cdPrtWL print line wavelengths in Angstroms in the standard format - a wrapper for prt_wl which must be kept parallel with sprt_wl both of those live in pdt.c

Parameters
[out]*ioOUToutput file handle
[in]theemission line wavelength

Definition at line 157 of file cddrive.cpp.

References DEBUG_ENTRY, and prt_wl().

Here is the call graph for this function:

◆ cdRead()

int cdRead ( const char * chInputLine)

cdRead This sends commands to the code. The normal set of commands described in Part I of Hazy must be entered into a null-terminated string. These strings are then fed to Cloudy with this command. The function returns the number of commands that can still be entered before the command stack is full. The code will stop if you try to continue giving it commands after the command has returned zero. This return value is the opposite of the standard - a non-zero return is normal

Definition at line 1752 of file cddrive.cpp.

References AS_SILENT_TRY, caps(), cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, GetQuote(), grid, input, INPUT_LINE_LENGTH, ioQQQ, lgcdInitCalled, lgInputComment(), NKRD, nMatch(), open_data(), optimize, save, strchr_s(), strstr_s(), TotalInsanity(), and trace.

Referenced by cdMain().

Here is the call graph for this function:

◆ cdReasonGeo()

void cdReasonGeo ( FILE * ioOUT)

This prints the reason why the model stopped, and the model geometry, on the io file pointed to by the file handle

Definition at line 175 of file cddrive.cpp.

References DEBUG_ENTRY, and warnings.

Referenced by PrtComment().

◆ cdSetExecTime()

void cdSetExecTime ( )

normally called by cdInit, this routine sets initial variables for times

Definition at line 474 of file cddrive.cpp.

References before, cdClock(), and lgCalled.

Referenced by cdInit().

Here is the call graph for this function:

◆ cdSurprises()

void cdSurprises ( FILE * ioOUT)

produces list of surprises

Definition at line 282 of file cddrive.cpp.

References DEBUG_ENTRY, and warnings.

Referenced by PrtComment().

◆ cdTalk()

void cdTalk ( bool lgTOn)

cdTalk tells the code whether or not to produce any of its normal output, If the argument is true (or if it is not called at all) it produces output, produces no output if it is false

Definition at line 1548 of file cddrive.cpp.

References called, cpu, and DEBUG_ENTRY.

◆ cdTemp()

int cdTemp ( const char * chLabel,
long int IonStage,
double * TeMean,
const char * chWeight )
Todo
2 this should have a last argument like cdIonFrac for whether or not weighting is wrt electron density

Definition at line 1602 of file cddrive.cpp.

References caps(), DEBUG_ENTRY, elementnames, HFLines, INPUT_LINE_LENGTH, ioQQQ, ipH1s, ipH2p, ipH_LIKE, ipHYDROGEN, iso_sp, LIMELM, mean, SDIV(), and SMALLFLOAT.

Referenced by DynaPunchTimeDep(), lgCheckMonitors(), optimize_func(), PrtFinal(), save_average(), and timestep_next().

Here is the call graph for this function:

◆ cdTemp_last()

double cdTemp_last ( )

cdTemp_last returns the temperature of the last zone on last iteration

Definition at line 1061 of file cddrive.cpp.

References phycon.

◆ cdTimescales()

void cdTimescales ( double * TTherm,
double * THRecom,
double * TH2 )

cdTimescales returns the longest thermal, recombination, and H2 formation timescales that occurred in the previous model

Parameters
*TThermthe thermal cooling timescale
*THRecomthe hydrogen recombination timescale
*TH2the H2 formation timescale

Definition at line 249 of file cddrive.cpp.

References DEBUG_ENTRY, MAX2, and timesc.

◆ cdVersion()

void cdVersion ( char chString[])

cdVersion The argument is a string with at least 8 characters that will receive a null terminated string with the version number of the code.

Definition at line 346 of file cddrive.cpp.

References Singleton< t_version >::Inst().

Here is the call graph for this function:

◆ cdWarnings()

void cdWarnings ( FILE * ioPNT)

These routines produce lists of warnings, cautions, notes, surprises These are the routines that are called by cdErrors. Normally cdErrors and not these routines would be called by the user.

Definition at line 198 of file cddrive.cpp.

References DEBUG_ENTRY, and warnings.

Referenced by cdErrors(), optimize_func(), PrtComment(), SaveLineIntensity(), SaveResults(), and ShowMe().

◆ debugLine()

long debugLine ( realnum wavelength)

debugLine provides a debugging hook into the main line array loops over whole array and finds every line that matches length, the wavelength, the argument to the function put breakpoint inside if test return value is number of matches, also prints all matches

Parameters
[in]theemission line wavelength
[out]thenumber of matches

Definition at line 1194 of file cddrive.cpp.

References LineSave, LineSv, wavelength, and WavlenErrorGet().

Here is the call graph for this function:

Variable Documentation

◆ before

struct timeval before
static

Definition at line 441 of file cddrive.cpp.

Referenced by cdExecTime(), and cdSetExecTime().

◆ lgCalled

bool lgCalled =false
static