00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "cddefines.h"
00010 #include "continuum.h"
00011 #include "prt.h"
00012 #include "rfield.h"
00013 #include "ipoint.h"
00014
00015 long ipoint(double energy_ryd)
00016 {
00017 long int i,
00018 ipoint_v;
00019
00020 DEBUG_ENTRY( "ipoint()" );
00021
00022 if( energy_ryd < continuum.filbnd[0] || energy_ryd > continuum.filbnd[continuum.nrange] )
00023 {
00024 fprintf( ioQQQ, " ipoint:\n" );
00025 fprintf( ioQQQ, " The energy_ryd array is not defined at nu=%11.3e. The bounds are%11.3e%11.3e\n",
00026 energy_ryd, continuum.filbnd[0], continuum.filbnd[continuum.nrange] );
00027 fprintf( ioQQQ, " ipoint is aborting to get trace, to find how this happened\n" );
00028 ShowMe();
00029 cdEXIT(EXIT_FAILURE);
00030 }
00031
00032 for( i=0; i < continuum.nrange; i++ )
00033 {
00034 if( energy_ryd >= continuum.filbnd[i] && energy_ryd <= continuum.filbnd[i+1] )
00035 {
00036
00037
00038
00039 ipoint_v = (long int)(log10(energy_ryd/continuum.filbnd[i])/continuum.fildel[i] +
00040 1.0 + continuum.ifill0[i]);
00041
00042 ASSERT( ipoint_v >= 0 );
00043
00044 ipoint_v = MIN2( rfield.nupper , ipoint_v );
00045
00046 DEBUG_EXIT( "ipoint()" );
00047 return ipoint_v;
00048 }
00049 }
00050
00051
00052 fprintf( ioQQQ, " IPOINT logic error, energy=%.2e\n",
00053 energy_ryd );
00054 puts( "[Stop in ipoint]" );
00055 cdEXIT(EXIT_FAILURE);
00056 }
00057
00058
00059
00060 long ipContEnergy(double energy,
00061 const char *chLabel)
00062 {
00063 long int ipConSafe_v;
00064
00065 DEBUG_ENTRY( "ipContEnergy()" );
00066
00067 ipConSafe_v = ipoint(energy);
00068
00069
00070 if( strcmp(rfield.chContLabel[ipConSafe_v-1]," ") == 0 )
00071 {
00072 strcpy( rfield.chContLabel[ipConSafe_v-1], chLabel );
00073 }
00074
00075
00076
00077 {
00078
00079 enum {DEBUG_LOC=false};
00080
00081 if( DEBUG_LOC )
00082 {
00083
00084 if( ipConSafe_v == 1296 )
00085 fprintf(ioQQQ,"%s\n", chLabel );
00086 }
00087 }
00088
00089 DEBUG_EXIT( "ipContEnergy()" );
00090 return ipConSafe_v;
00091 }
00092
00093
00094
00095
00096 long ipLineEnergy(double energy,
00097
00098 const char *chLabel ,
00099
00100 long ipIonEnergy )
00101 {
00102 long int ipLine_ret;
00103
00104 DEBUG_ENTRY( "ipLineEnergy()" );
00105
00106 ipLine_ret = ipoint(energy);
00107 ASSERT( ipLine_ret );
00108
00109 if( ipIonEnergy > 0 )
00110 {
00111 ipLine_ret = MIN2( ipLine_ret , ipIonEnergy-1 );
00112 }
00113
00114 ASSERT( ipLine_ret > 0 );
00115
00116
00117
00118
00119
00120 if( !rfield.line_count[ipLine_ret-1] )
00121 {
00122 strcpy( rfield.chLineLabel[ipLine_ret-1], chLabel );
00123 }
00124
00125 ++rfield.line_count[ipLine_ret-1];
00126
00127
00128
00129 {
00130
00131 enum {DEBUG_LOC=false};
00132
00133 if( DEBUG_LOC )
00134 {
00135
00136 if( ipLine_ret == 2795 )
00137 fprintf(ioQQQ,"%s\n", chLabel );
00138 }
00139 }
00140
00141
00142 if( prt.lgPrtContIndices )
00143 {
00144
00145 static bool lgFirst = true;
00146 if( lgFirst )
00147 {
00148
00149 fprintf(ioQQQ , "\n\noutput from print continuum indices command follows.\n");
00150 fprintf(ioQQQ , "cont ind (F scale)\tenergy(ryd)\tlabel\n");
00151 lgFirst = false;
00152 }
00153 if( energy >= prt.lgPrtContIndices_lo_E && energy <= prt.lgPrtContIndices_hi_E )
00154 {
00155
00156
00157
00158
00159 if( energy < 1. )
00160 {
00161 fprintf(ioQQQ , "%li\t%.3e\t%s\n" , ipLine_ret , energy , chLabel);
00162 }
00163 else if( energy < 10. )
00164 {
00165 fprintf(ioQQQ , "%li\t%.3f\t%s\n" , ipLine_ret , energy , chLabel);
00166 }
00167 else if( energy < 100. )
00168 {
00169 fprintf(ioQQQ , "%li\t%.2f\t%s\n" , ipLine_ret , energy , chLabel);
00170 }
00171 else
00172 {
00173 fprintf(ioQQQ , "%li\t%.1f\t%s\n" , ipLine_ret , energy , chLabel);
00174 }
00175 }
00176 }
00177
00178 DEBUG_EXIT( "ipLineEnergy()" );
00179 return ipLine_ret;
00180 }
00181
00182
00183 long ipFineCont(
00184
00185 double energy_ryd )
00186 {
00187 long int ipoint_v;
00188
00189 DEBUG_ENTRY( "ipFineCont()" );
00190
00191 if( energy_ryd < rfield.fine_ener_lo || energy_ryd > rfield.fine_ener_hi )
00192 {
00193 DEBUG_EXIT( "ipFineCont()" );
00194 return -1;
00195 }
00196
00197
00198
00199
00200
00201
00202
00203 ipoint_v = (long int)(log10(energy_ryd*(1.-rfield.fine_resol/2.) /
00204 rfield.fine_ener_lo)/log10(1.+rfield.fine_resol));
00205
00206 ASSERT( ipoint_v >= 0 && ipoint_v< rfield.nfine_malloc );
00207
00208 DEBUG_EXIT( "ipFineCont()" );
00209 return ipoint_v;
00210 }