00001
00002
00003
00004 #include "cddefines.h"
00005
00006 #include "physconst.h"
00007 #include "optimize.h"
00008 #include "radius.h"
00009 #include "iterations.h"
00010 #include "input.h"
00011 #include "parser.h"
00012
00013 void ParseRadius(Parser &p)
00014 {
00015 bool
00016 lgR2set,
00017 lgRLog;
00018 double a,
00019 convl,
00020 r;
00021
00022 DEBUG_ENTRY( "ParseRadius()" );
00023
00024
00025
00026
00027 convl = p.nMatch("PARS") ? log10( PARSEC ) : 0.;
00028
00029
00030 lgRLog = !p.nMatch("LINE");
00031
00032 r = p.FFmtRead();
00033 if( p.lgEOL() )
00034 p.NoNumb("radius");
00035
00036
00037 if( lgRLog )
00038 {
00039 r += convl;
00040 }
00041 else
00042 {
00043 if( r > 0. )
00044 {
00045 r = log10(r) + convl;
00046 }
00047 else
00048 {
00049 fprintf(ioQQQ,"The first radius is negative and linear is set - this is impossible.\n");
00050 cdEXIT(EXIT_FAILURE);
00051 }
00052 }
00053
00054 if( r > 37. || r < -37. )
00055 {
00056 fprintf(ioQQQ,"WARNING - the log of the radius is %e - this is too big.\n", r );
00057 fprintf(ioQQQ," Sorry.\n" );
00058 cdEXIT(EXIT_FAILURE);
00059 }
00060
00061 radius.Radius = pow(10.,r);
00062 radius.lgRadiusKnown = true;
00063
00064
00065 a = p.FFmtRead();
00066 if( p.lgEOL() )
00067 {
00068
00069 lgR2set = false;
00070 }
00071 else
00072 {
00073
00074 lgR2set = true;
00075
00076
00077 if( lgRLog )
00078 {
00079 a += convl;
00080 }
00081 else
00082 {
00083
00084 if( a > 0. )
00085 {
00086 a = log10(a) + convl;
00087 }
00088 else
00089 {
00090 fprintf(ioQQQ,"The second radius is negative and linear is set - this is impossible.\n");
00091 cdEXIT(EXIT_FAILURE);
00092 }
00093 }
00094
00095 if( a > 37. || a < -37. )
00096 {
00097 fprintf(ioQQQ,"WARNING - the log of the second radius is %e - this is too big.\n", a );
00098
00099 fflush( ioQQQ );
00100 }
00101 a = pow(10.,a);
00102
00103
00104
00105 if( a > radius.Radius )
00106 radius.StopThickness[0] = a - radius.Radius;
00107 else
00108 radius.StopThickness[0] = a;
00109
00110 for( long int i=1; i < iterations.iter_malloc; i++ )
00111 {
00112 radius.StopThickness[i] = radius.StopThickness[0];
00113 }
00114 }
00115
00116
00117 if( optimize.lgVarOn )
00118 {
00119
00120 optimize.nvfpnt[optimize.nparm] = input.nRead;
00121
00122
00123 if( lgR2set )
00124 {
00125 strcpy( optimize.chVarFmt[optimize.nparm], "RADIUS %f depth or outer R %f LOG" );
00126 optimize.nvarxt[optimize.nparm] = 2;
00127
00128 optimize.vparm[1][optimize.nparm] = (realnum)log10(a);
00129 fprintf(ioQQQ,
00130 " WARNING - outer radius or thickness was set with a variable radius.\n");
00131 fprintf(ioQQQ,
00132 " The interpretation of the second number can change from radius to depth as radius changes.\n");
00133 fprintf(ioQQQ,
00134 " Do not use the second parameter unless you are certain that you know what you are doing.\n");
00135 fprintf(ioQQQ,
00136 " Consider using the STOP THICKNESS or STOP RADIUS command instead.\n");
00137 }
00138 else
00139 {
00140 strcpy( optimize.chVarFmt[optimize.nparm], "RADIUS= %f LOG" );
00141 optimize.nvarxt[optimize.nparm] = 1;
00142 }
00143
00144
00145 optimize.vparm[0][optimize.nparm] = (realnum)log10(radius.Radius);
00146 optimize.vincr[optimize.nparm] = 0.5;
00147 ++optimize.nparm;
00148 }
00149 return;
00150 }