cloudy
trunk
|
#include "cddefines.h"
#include "cddrive.h"
#include "trace.h"
#include "conv.h"
#include "init.h"
#include "lines.h"
#include "pressure.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 "grid.h"
#include "timesc.h"
#include "cloudy.h"
#include "warnings.h"
#include "broke.h"
#include "iso.h"
#include "save.h"
#include "rfield.h"
#include "lines_service.h"
#include "service.h"
#include "parser.h"
#include "generic_state.h"
#include "prt.h"
#include "noexec.h"
#include <sys/time.h>
#include <sys/resource.h>
Go to the source code of this file.
Functions | |
int | cdDrive () |
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 () |
long | cdMemory () |
void | cdPrintCommands (FILE *ioOUT) |
void | cdEmis (const 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 string &filename, const char *mode) |
void | cdOutput (const string &filename, FILE *fp) |
void | cdInput (const string &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 |
double cdB21cm | ( | ) |
cdB21cm returns B as measured by 21 cm assumes tangled field weighted by n(H0)/T
Definition at line 1270 of file cddrive.cpp.
References DEBUG_ENTRY, mean, SMALLFLOAT, and t_mean::TempB_HarMean.
Referenced by PrtFinal().
void cdCautions | ( | FILE * | ) |
produces list of cautions
Definition at line 219 of file cddrive.cpp.
References t_warnings::chCaunln, DEBUG_ENTRY, fprintf(), t_warnings::ncaun, and warnings.
Referenced by cdErrors(), PrtComment(), SaveLineIntensity(), SaveResults(), and ShowMe().
STATIC void cdClock | ( | struct timeval * | clock_dat | ) |
Definition at line 441 of file cddrive.cpp.
References cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, fprintf(), and ioQQQ.
Referenced by cdExecTime(), and cdSetExecTime().
void cdClosePunchFiles | ( | ) |
wrapper to close all save files
Definition at line 1644 of file cddrive.cpp.
References CloseSaveFiles(), and DEBUG_ENTRY.
int cdColm | ( | const char * | chLabel, |
long int | ion, | ||
double * | theocl | ||
) |
Definition at line 592 of file cddrive.cpp.
References caps(), cdH2_colden(), t_elementnames::chElementNameShort, column(), molezone::column, DEBUG_ENTRY, dense, elementnames, findspecieslocal(), fprintf(), ioQQQ, ipHe2s3S, ipHE_LIKE, ipHELIUM, ipHYDROGEN, iso_sp, t_dense::lgElmtOn, LIMELM, matchGeneric(), MAX2, mean, NCHLAB, genericState::q, genericState::sp, t_iso_sp::st, trimTrailingWhiteSpace(), and t_mean::xIonMean.
Referenced by lgCheckMonitors(), optimize_func(), PrtColumns(), save_average(), and SaveDo().
double cdCooling_last | ( | ) |
cdCooling_last The returns the total cooling (erg cm^-3 s^-1) for the last computed zone
Definition at line 334 of file cddrive.cpp.
References t_thermal::ctot, and thermal.
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 362 of file cddrive.cpp.
References Singleton< t_version >::Inst().
void cdDepth_depth | ( | double | cdDepth[] | ) |
returns depth structure of previous model
cdDepth[] |
Definition at line 813 of file cddrive.cpp.
References DEBUG_ENTRY, t_struc::depth, nzone, and struc.
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 81 of file cddrive.cpp.
References cdEXIT, cloudy(), DEBUG_ENTRY, EXIT_FAILURE, fprintf(), grid, grid_do(), InitCoreload(), t_mesh::InitMesh(), input, ioQQQ, lgAbort, lgcdInitCalled, t_grid::lgInsideGrid, t_optimize::lgNoVary, t_optimize::lgOptimr, t_trace::lgTrace, t_optimize::lgVaryOn, t_mesh::ncells(), t_rfield::nflux, t_rfield::nflux_with_check, t_rfield::nPositive, t_input::nSave, optimize, rfield, and trace.
Referenced by cdMain().
double cdEDEN_last | ( | ) |
cdEDEN_last return electron density of last zone
Definition at line 389 of file cddrive.cpp.
References dense, and t_dense::eden.
void cdEmis | ( | const char * | chLabel, |
realnum | wavelength, | ||
double * | emiss, | ||
bool | lgEmergent | ||
) |
cdEms obtain the local emissivity for a line, for the last computed zone
Definition at line 552 of file cddrive.cpp.
References cdEmis(), DEBUG_ENTRY, t_LineSave::findline(), t_LineSave::lines, and LineSave.
Referenced by cdEmis(), and cdEmis_ip().
void cdEmis_ip | ( | long int | ipLine, |
double * | emiss, | ||
bool | lgEmergent | ||
) |
cdEms_ip obtain the local emissivity for a line with known index
ipLine | index of the line in the stack |
*emiss | the vol emissivity of this line in last computed zone |
lgEmergent | intrinsic or emergent emissivities |
Definition at line 570 of file cddrive.cpp.
References ASSERT, cdEmis(), DEBUG_ENTRY, t_LineSave::lines, LineSave, and t_LineSave::nsum.
Referenced by save_line().
void cdErrors | ( | FILE * | ) |
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
[out] | *ioOUT | output file |
Definition at line 747 of file cddrive.cpp.
References cdCautions(), cdNwcns(), cdWarnings(), t_input::chTitle, DEBUG_ENTRY, fprintf(), and input.
double cdExecTime | ( | ) |
cdExecTime returns the elapsed time cpu time (sec) that has elapsed since cdInit called cdSetExecTime.
Definition at line 478 of file cddrive.cpp.
References before, cdClock(), cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, fprintf(), ioQQQ, and lgCalled.
Referenced by cdMain(), PrtFinal(), and SaveDo().
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 t_thermal::htot, and thermal.
void cdInput | ( | const string & | 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 1232 of file cddrive.cpp.
References AS_LOCAL_ONLY_TRY, cdEXIT, DEBUG_ENTRY, ES_FAILURE, fprintf(), ioQQQ, ioStdin, and open_data().
Referenced by cdMain(), and cdPrepareExit().
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
*chLabel | four char string, null terminated, giving the element name |
IonStage | IonStage is ionization stage, 1 for atom, up to N+1 where N is atomic number |
*fracin | will be fractional ionization |
*chWeight | how to weight the average, must be "VOLUME" or "RADIUS" |
lgDensity | if true then weighting also has electron density, if false then only volume or radius |
Definition at line 909 of file cddrive.cpp.
References caps(), t_elementnames::chElementNameShort, DEBUG_ENTRY, elementnames, exp10(), fprintf(), INPUT_LINE_LENGTH, ioQQQ, ipHYDROGEN, LIMELM, mean, t_mean::MeanIon(), and trimTrailingWhiteSpace().
Referenced by DynaPunchTimeDep(), lgCheckMonitors(), and save_average().
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.
*chLabel | 1st parameter is the 4-char label + null terminated label, as it appears in the output. |
wavelength | 2nd 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). |
*relint | 5th is pointer to relative intensity, a double that is returned |
*absint | 6th is pointer to log of absolute intensity |
lEmergent | - emergent or intrinsic intensity |
Definition at line 1067 of file cddrive.cpp.
References cdLine(), and DEBUG_ENTRY.
Referenced by cdLine(), ConvIterCheck(), Drive_cdLine(), IterStart(), lgCheckMonitors(), lines(), PrtComment(), PrtFinal(), and SaveDo().
long int cdLine | ( | const char * | chLabel, |
realnum | wavelength, | ||
double * | relint, | ||
double * | absint, | ||
int | LineType | ||
) |
Definition at line 1080 of file cddrive.cpp.
References cdLine_ip(), DEBUG_ENTRY, t_LineSave::findline(), and LineSave.
void cdLine_ip | ( | long int | ipLine, |
double * | relint, | ||
double * | absint | ||
) |
Definition at line 1110 of file cddrive.cpp.
References cdLine_ip(), and DEBUG_ENTRY.
Referenced by cdLine(), cdLine_ip(), lgCheckMonitors(), PrtLineSum(), and save_line().
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
ipLine | |
*relint | linear intensity relative to normalization line |
*absint | log of luminosity or intensity of line |
lgEmergent | - intrinsic or emergent intensity |
Definition at line 1120 of file cddrive.cpp.
References ASSERT, t_radius::Conv2PrtInten, DEBUG_ENTRY, fprintf(), ioQQQ, t_LineSave::ipNormWavL, t_LineSave::lines, LineSave, t_LineSave::nsum, radius, and t_LineSave::ScaleNormLine.
long cdMemory | ( | ) |
Definition at line 503 of file cddrive.cpp.
References cdEXIT, EXIT_FAILURE, fprintf(), and ioQQQ.
Referenced by cdMain().
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 403 of file cddrive.cpp.
References DEBUG_ENTRY, t_noexec::lgNoExec, and noexec.
void cdNotes | ( | FILE * | ) |
produces list of Notes
Definition at line 310 of file cddrive.cpp.
References t_warnings::chNoteln, DEBUG_ENTRY, fprintf(), t_warnings::nnote, and warnings.
Referenced by PrtComment().
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
*lgAbort | abort status, if non-zero then big problems happened |
*NumberWarnings | the number of warnings |
*NumberCautions | the number of cautions |
*NumberNotes | the number of notes |
*NumberSurprises | the number of surprises |
*NumberTempFailures | the number of temperature convergence failures |
*NumberPresFailures | the number of pressure convergence failures |
*NumberIonFailures | the number of ionization convergence failures |
*NumberNeFailures | the number of electron density convergence failures |
Definition at line 1173 of file cddrive.cpp.
References conv, DEBUG_ENTRY, lgAbort, t_warnings::nbang, t_warnings::ncaun, t_conv::nIonFail, t_conv::nNeFail, t_warnings::nnote, t_conv::nPreFail, t_conv::nTeFail, t_warnings::nwarn, and warnings.
Referenced by cdErrors(), cdMain(), and PrtComment().
long int cdnZone | ( | ) |
void cdOutput | ( | const string & | 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 1209 of file cddrive.cpp.
References AS_LOCAL_ONLY, t_save::chOutputFile, DEBUG_ENTRY, ioQQQ, open_data(), and save.
Referenced by cdMain(), and cdPrepareExit().
void cdOutput | ( | const string & | filename, |
FILE * | fp | ||
) |
Definition at line 1222 of file cddrive.cpp.
References t_save::chOutputFile, DEBUG_ENTRY, ioQQQ, and save.
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
TotalPressure[] | total pressure, all forms |
GasPressure[] | gas pressure |
RadiationPressure[] | radiation pressure |
Definition at line 838 of file cddrive.cpp.
References DEBUG_ENTRY, t_struc::GasPressure, nzone, t_struc::pres_radiation_lines_curr, t_struc::pressure, and struc.
void cdPressure_last | ( | double * | TotalPressure, |
double * | GasPressure, | ||
double * | RadiationPressure | ||
) |
cdPressure_last
This returns the pressure and its constituents for the last computed zone.
*TotalPressure | total pressure, all forms |
*GasPressure | gas pressure |
*RadiationPressure | radiation pressure |
Definition at line 865 of file cddrive.cpp.
References DEBUG_ENTRY, t_pressure::pres_radiation_lines_curr, t_pressure::PresGasCurr, pressure, and t_pressure::PresTotlCurr.
void cdPrintCommands | ( | FILE * | ) |
cdPrintCommands( FILE *) This routine prints all input commands into file whose handle is the argument
*ioOUT | [out] output file handle |
Definition at line 527 of file cddrive.cpp.
References t_input::chCardSav, fprintf(), t_input::InclLevel, input, and t_input::nSave.
Referenced by ShowMe().
int cdRead | ( | const char * | ) |
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 1466 of file cddrive.cpp.
References AS_SILENT_TRY, cdEXIT, t_input::chCardSav, t_input::chCardStrip, t_save::chOutputFile, t_input::curInclLevel, DEBUG_ENTRY, EXIT_FAILURE, exp10(), fprintf(), Parser::getNumberDefault(), grid, Parser::hasCommand(), t_input::InclLevel, input, INPUT_LINE_LENGTH, ioQQQ, lgcdInitCalled, t_grid::lgGrid, t_input::lgInitPresent, lgIsCommentSeq(), t_optimize::lgNoVary, t_optimize::lgOptimr, t_prt::lgPrintTime, t_input::lgSetNoBuffering, t_trace::lgTrace, t_optimize::lgVaryOn, min(), t_grid::nGridCommands, NKRD, Parser::nMatch(), t_input::nSave, open_data(), optimize, ParseInit(), prt, rfield, save, Parser::setline(), t_mesh::setResolutionScaleFactor(), StripComment(), and trace.
Referenced by cdMain(), and ParseInit().
void cdReasonGeo | ( | FILE * | ) |
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 170 of file cddrive.cpp.
References t_warnings::chRgcln, DEBUG_ENTRY, fprintf(), and warnings.
Referenced by PrtComment().
void cdSetExecTime | ( | ) |
void cdSurprises | ( | FILE * | ) |
produces list of surprises
Definition at line 274 of file cddrive.cpp.
References broke, t_warnings::chBangln, DEBUG_ENTRY, fprintf(), Singleton< FixitList >::Inst(), t_broke::lgPrintFixits, FixitList::list, t_warnings::nbang, and warnings.
Referenced by PrtComment().
void cdTalk | ( | bool | ) |
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 1257 of file cddrive.cpp.
References called, cpu, DEBUG_ENTRY, t_cpu::i(), t_cpu_i::lgMPI_talk(), t_called::lgTalk, and t_called::lgTalkForcedOff.
int cdTemp | ( | const char * | chLabel, |
long int | IonStage, | ||
double * | TeMean, | ||
const char * | chWeight | ||
) |
Definition at line 1311 of file cddrive.cpp.
References caps(), t_elementnames::chElementNameShort, DEBUG_ENTRY, elementnames, TransitionProxy::Emis(), TransitionList::Emis(), exp10(), fprintf(), HFLines, INPUT_LINE_LENGTH, ioQQQ, ipH1s, ipH2p, ipH_LIKE, ipHYDROGEN, iso_sp, LIMELM, mean, t_mean::MeanIon(), SMALLFLOAT, EmissionProxy::TauCon(), t_mean::TempEdenMean, t_mean::TempH_21cmSpinMean, t_mean::TempHarMean, t_mean::TempIonMean, t_mean::TempMean, t_iso_sp::trans(), and trimTrailingWhiteSpace().
Referenced by DynaPunchTimeDep(), lgCheckMonitors(), optimize_func(), PrtFinal(), and save_average().
double cdTemp_last | ( | ) |
cdTemp_last returns the temperature of the last zone on last iteration
Definition at line 898 of file cddrive.cpp.
References phycon, and t_phycon::te.
void cdTimescales | ( | double * | TTherm, |
double * | THRecom, | ||
double * | TH2 | ||
) |
cdTimescales returns the longest thermal, recombination, and H2 formation timescales that occurred in the previous model
*TTherm | the thermal cooling timescale |
*THRecom | the hydrogen recombination timescale |
*TH2 | the H2 formation timescale |
Definition at line 242 of file cddrive.cpp.
References DEBUG_ENTRY, MAX2, t_timesc::time_H2_Dest_longest, t_timesc::time_H2_Form_longest, t_timesc::time_Hrecom_long, t_timesc::time_therm_long, and timesc.
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 347 of file cddrive.cpp.
References Singleton< t_version >::Inst().
void cdWarnings | ( | FILE * | ) |
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 192 of file cddrive.cpp.
References t_warnings::chWarnln, DEBUG_ENTRY, fprintf(), t_warnings::nwarn, and warnings.
Referenced by cdErrors(), optimize_func(), PrtComment(), SaveLineIntensity(), SaveResults(), and ShowMe().
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
[in] | the | emission line wavelength |
[out] | the | number of matches |
Definition at line 1032 of file cddrive.cpp.
References t_LineSave::lines, LineSave, t_LineSave::nsum, t_LineSave::sig_figs, wavelength, and WavlenErrorGet().
|
static |
Definition at line 438 of file cddrive.cpp.
Referenced by cdExecTime(), and cdSetExecTime().
|
static |
Definition at line 424 of file cddrive.cpp.
Referenced by cdExecTime(), cdSetExecTime(), ContBandsCreate(), da(), and ParseTable().