Cloudy & Associates

Commit 29b3246b authored by Robin Williams's avatar Robin Williams
Browse files

Merge branch '452-optimize-column-density-fails-for-molecules' into 'master'

Resolve "Optimize column density fails for molecules"

Closes #452

See merge request !32
parents 6446d20a 0e9e1924
......@@ -181,13 +181,17 @@ to match.
\subsection{Optimize column density}
This specifies a set of column densities.
A series of column densities,
This specifies a set of column densities to be optimized.
A series of species and constraints are read,
ending with a line with the keyword \cdCommand{end} in columns 1 to 3,
will be read
in from subsequent lines.
One column density is entered per line and there is no limit to
One species is entered per line and there is no limit to
the number of entries.
The species can be specified in one of two ways:
\cdTerm{Atomic ions:}
Columns 1 to 4 of the column density lines must
contain the first four characters of the name of the element spelled as
in the output from the zone results.
......@@ -211,34 +215,36 @@ silicon 3 14.6 # The Si+2 column density
end of column densities
\end{verbatim}
\cdTerm{Molecular and level column densities: how this command works:}
The label
and ion that are parsed from the lines giving the column densities
\cdTerm{Molecular and level column densities:}
The species is specified as a quoted, case-sensitive string, and no ionization
stage is specified. (This is different from previous
versions of Cloudy, where the species did not need to be quoted, but
only the first 4 characters were used, and an ionization stage
of 0 had to be specified.)
The species names which are parsed from the lines giving the column density
constraints
are simply
passed to routine \cdTerm{cdColm}.
That routine is described in Part 2 of \Hazy.
This optimization command accepts any species that
\cdTerm{cdColm} recognizes.
Column densities of molecules and excited states of some ions
can be specified by entering an ion stage of zero and one of the strings
that is described where \cdTerm{cdColm} is described.
The first four characters
of the label given on the input line must agree with those listed there.
can be specified by special syntax, and one of the cases
that is described where \cdTerm{cdColm} is shown in the example below.
The following shows some examples of optimizing molecular and state column
densities:
\begin{verbatim}
optimize column densities
H- 0 < 17 # The H- column density is a limit
H2 0 17.4 error =.001 # Match the H_2 column density exactly
H2+ 0 14.6 # The H2+ molecular ion
O11* 0 16.3 # This is an excited level within the O^0 ground term
"H-" < 17 # The H- column density is a limit
"H2" 17.4 error =.001 # Match the total H_2 column density exactly
"H2+" 14.6 # The H2+ molecular ion
"O11*" 16.3 # This is an excited level within the O^0 ground term
"He+[2]" 16.3 # This selects just one level from the He+ ion
"CO[2]" 16.3 # This is a level in the CO molecule
"CO[1:3]" 18.3 # This is the sum of levels 1,2,3 in the CO molecule
end of column densities
\end{verbatim}
Note that extra spaces were placed after the labels for the molecules to
pad out the needed four-character label.
The ion, the first number after
the four-character label, is always zero
\subsection{Optimize, [intensity, luminosity]=36.425 [error =0.1]}
......
......@@ -84,19 +84,25 @@ announce it.
Table \ref{tab:AutoSimulationList} lists the simulations in the
\cdFilename{auto} test directory.
\begin{table}
\centering
\caption{
The simulations in the auto test suite.}
\begin{tabular}{ c c }
%\begin{longtable}{>{\centering}p{0.2\textwidth}>{\centering}p{0.7\textwidth}}
\begin{longtable}{cp{0.7\textwidth}}
\caption{The simulations in the auto test suite.}\\
\hline
Class & Function \\
Class & Function\\
\hline
\input{../../../tsuite/auto/doc_tsuite.txt}
\endfirsthead
\caption{(continued)}\\
\hline
Class & Function\\
\hline
\endhead
\hline\multicolumn{2}{r}{\textit{Continued on next page}}
\endfoot
\hline
\endlastfoot
\input{../../../tsuite/auto/doc_tsuite.txt}
\label{tab:AutoSimulationList}
\end{tabular}
\end{table}
\end{longtable}
\includepdf[pages=-]{../../../tsuite/auto/doc_tsuite.pdf}
......@@ -105,19 +111,24 @@ Class & Function \\
Table \ref{tab:SlowSimulationList} lists the simulations in the
\cdFilename{slow} test directory.
\begin{table}
\centering
\caption{
The simulations in the slow test suite.}
\begin{tabular}{ c c }
\begin{longtable}{cp{0.7\textwidth}}
\caption{The simulations in the slow test suite.}\\
\hline
Class & Function \\
Class & Function\\
\hline
\input{../../../tsuite/slow/doc_tsuite.txt}
\endfirsthead
\caption{(continued)}\\
\hline
Class & Function\\
\hline
\endhead
\hline\multicolumn{2}{r}{\textit{Continued on next page}}
\endfoot
\hline
\endlastfoot
\input{../../../tsuite/slow/doc_tsuite.txt}
\label{tab:SlowSimulationList}
\end{tabular}
\end{table}
\end{longtable}
\includepdf[pages=-]{../../../tsuite/slow/doc_tsuite.pdf}
......
......@@ -54,6 +54,11 @@ top=2.5cm,bottom=2.5cm]{geometry}
% allow external files to be included verbatim
\usepackage{moreverb}
% allow tables to wrap over pages
\usepackage{longtable}
% set the default tabsize
\def\verbatimtabsize{4\relax}
......
......@@ -154,8 +154,18 @@ chi2_type optimize_func(const realnum param[],
cdWarnings(ioQQQ);
/* print header before any of the individual chi2 values are printed */
int wlab = 4;
for( i=0; i < long(optimize.chTempLab.size()); i++ )
{
wlab = max(wlab,optimize.chTempLab[i].size());
}
for( i=0; i < long(optimize.chColDen_label.size()); i++ )
{
wlab = max(wlab,optimize.chColDen_label[i].size());
}
if( optimize.lgOptimize )
fprintf( ioQQQ, " ID Model Observed error chi**2 Type\n" );
fprintf( ioQQQ, " %*.*s%7s%12.12s%12.12s%12.12s%12.12s Type\n",
wlab,wlab,"ID","","Model","Observed","error","chi**2");
else
ASSERT( grid.lgGrid );
......@@ -251,7 +261,8 @@ chi2_type optimize_func(const realnum param[],
nobs_cat[cat]++;
chi2_cat[cat] += chi1;
fprintf( ioQQQ, " %4.4s%7ld%12.4e%12.4e%12.5f%12.2e Temperature\n",
fprintf( ioQQQ, " %*.*s%7ld%12.4e%12.4e%12.5f%12.2e Temperature\n",
wlab, wlab,
optimize.chTempLab[i].c_str(), optimize.ionTemp[i], temp_theory,
optimize.temp_obs[i], optimize.temp_error[i], chi1 );
}
......@@ -272,8 +283,9 @@ chi2_type optimize_func(const realnum param[],
cat = 1;
nobs_cat[cat]++;
chi2_cat[cat] += chi1;
fprintf( ioQQQ, " %4.4s%7ld%12.4e%12.4e%12.5f%12.2e Column density\n",
fprintf( ioQQQ, " %*.*s%7ld%12.4e%12.4e%12.5f%12.2e Column density\n",
wlab,wlab,
optimize.chColDen_label[i].c_str(), optimize.ion_ColDen[i], theocl,
optimize.ColDen_Obs[i], optimize.ColDen_error[i], chi1 );
}
......
......@@ -304,31 +304,48 @@ STATIC void GetOptColDen(Parser &p )
while( !p.m_lgEOF )
{
/* order on line is element label (col 1-4), ionization stage, column density, err */
/* copy cap'd version of first 4 char of chCard to chColDen_label */
optimize.chColDen_label.push_back(elementnames.chElementNameShort[p.getElement()]);
/* now get the ion stage, this should be 1 for atom, up to element
* number plus one */
long ion = nint(p.FFmtRead());
if( p.lgEOL() )
string chLabel;
if ( p.GetQuote( chLabel ) == 0 )
{
p.PrintLine( ioQQQ );
fprintf( ioQQQ, " The ionization stage MUST appear on this line. Sorry.\n" );
cdEXIT(EXIT_FAILURE);
// Read a quote-delimited string, which will be interpreted
// by cdColm as a generic species label. It would be better
// to do the lookup earlier, to validate the input and save
// repeated effort.
/* order on line is species, column density, err */
optimize.chColDen_label.push_back(chLabel);
optimize.ion_ColDen.push_back(0);
}
/* the ion must be 1 or greater unless requesting a special,
* like a molecule or excited state population, in which
* case ion = 0
* can't check on upper limit yet since have not resolved element name */
if( ion < 0 )
else
{
p.PrintLine( ioQQQ );
fprintf( ioQQQ, " An ionization stage of %ld does not make sense. Sorry.\n", ion );
cdEXIT(EXIT_FAILURE);
/* order on line is element name (at least 4 characters), ionization stage, column density, err */
/* copy cap'd version of first 4 char of chCard to chColDen_label */
// The other branch can handle also ions, with the 'chemical'
// syntax '"H+"' (in quotes), rather than 'HYDR 2' below
optimize.chColDen_label.push_back(elementnames.chElementNameShort[p.getElement()]);
/* now get the ion stage, this should be 1 for atom, up to element
* number plus one */
long ion = nint(p.FFmtRead());
if( p.lgEOL() )
{
p.PrintLine( ioQQQ );
fprintf( ioQQQ, " The ionization stage MUST appear on this line. Sorry.\n" );
cdEXIT(EXIT_FAILURE);
}
/* the ion must be 1 or greater unless requesting a special,
* like a molecule or excited state population, in which
* case ion = 0
* can't check on upper limit yet since have not resolved element name */
if( ion < 0 )
{
p.PrintLine( ioQQQ );
fprintf( ioQQQ, " An ionization stage of %ld does not make sense. Sorry.\n", ion );
cdEXIT(EXIT_FAILURE);
}
optimize.ion_ColDen.push_back(ion);
}
optimize.ion_ColDen.push_back(ion);
optimize.ColDen_Obs.push_back( realnum(exp10(p.FFmtRead())) );
if( p.lgEOL() )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment