コード例 #1
0
        public bool PostEvaluate(IAgAsHpopPluginResultPostEval ResultEval)
        {
            try
            {
                if (this.m_MsgCntr % this.m_MsgInterval == 0)
                {
                    Debug.WriteLine("--> Entered", this.m_Name + ".PostEvaluate( " + this.m_MsgCntr + " )");
                }

                if (m_Enabled && m_DebugMode && ResultEval != null)
                {
                    // get SRP acceleration from HPOP

                    Tuple3 srpAccel = new Tuple3(0.0, 0.0, 0.0);

                    ResultEval.GetAcceleration(AgEAccelType.eSRPAccel, AgEUtFrame.eUtFrameInertial,
                                               ref srpAccel.x, ref srpAccel.y, ref srpAccel.z);

                    DebugMsg("HPOP computed Sunlight SRP = (" + srpAccel.x + ", " + srpAccel.y + ", " + srpAccel.z + ")");

                    srpAccel.scaleBy(-1.0);
                    srpAccel.addTo(this.m_SunlightSRP);

                    DebugMsg("Difference in Sunlight SRP = (" + srpAccel.x + ", " + srpAccel.y + ", " + srpAccel.z + ")");

                    double cr        = ResultEval.Cr;
                    double dragArea  = ResultEval.DragArea;
                    double solarFlux = ResultEval.SolarFlux;
                    double illum     = ResultEval.SolarIntensity;

                    DebugMsg("Area = " + dragArea + ", Flux = " + solarFlux + ", Cr = " + cr + ",  Mass = " + m_SpacecraftMass + ", Illum = " + illum);
                }
                else if (this.m_DebugMode)
                {
                    this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".PostEvaluate(): Disabled");
                }
            }
            catch (Exception ex)
            {
                this.m_Enabled = false;

                Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".PostEvaluate(): Exception Message( " + ex.Message + " )");
                Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".PostEvaluate(): Exception StackTr( " + ex.StackTrace + " )");

                Debug.WriteLine("Exception Message( " + ex.Message + " )", this.m_Name + ".PostEvaluate()");
                Debug.WriteLine("Exception StackTr( " + ex.StackTrace + " )", this.m_Name + ".PostEvaluate()");
            }
            finally
            {
                if (this.m_MsgCntr % this.m_MsgInterval == 0)
                {
                    Debug.WriteLine("<-- Exited", this.m_Name + ".PostEvaluate( " + this.m_MsgCntr + " )");
                }
            }

            m_EvalMsgCount++;

            if (m_EvalMsgCount % m_EvalMsgMax == 0)
            {
                m_EvalMsgsOn = false;
            }

            return(this.m_Enabled);
        }
        private bool setSphericalReflectanceUsingFrame(AgAsLightReflectionResultEval ResultEval, double cr, AgEUtFrame frame)
        {
            double reflectanceMag;

            Tuple3 incidentVec = new Tuple3();

            ResultEval.IncidentDirection((AgEUtFrame)frame, ref incidentVec.x, ref incidentVec.y, ref incidentVec.z);

            // reflectance is positive along the incident direction

            incidentVec.scaleBy(m_SRPArea);

            if (m_CrIndex > -1)
            {
                ResultEval.SetReflectanceParamPartials(m_CrIndex, frame, incidentVec.x, incidentVec.y, incidentVec.z);
            }

            incidentVec.scaleBy(cr);

            ResultEval.SetReflectance((AgEUtFrame)frame, incidentVec.x, incidentVec.y, incidentVec.z);

            double[,] incidentDirPosPartials, posPartials;

            incidentDirPosPartials = new double[3, 3];
            posPartials            = new double[3, 3];

            ResultEval.IncidentDirectionCompPosPartials((AgEUtFrame)frame,
                                                        ref incidentDirPosPartials[0, 0], ref incidentDirPosPartials[0, 1], ref incidentDirPosPartials[0, 2],
                                                        ref incidentDirPosPartials[1, 0], ref incidentDirPosPartials[1, 1], ref incidentDirPosPartials[1, 2],
                                                        ref incidentDirPosPartials[2, 0], ref incidentDirPosPartials[2, 1], ref incidentDirPosPartials[2, 2]);

            reflectanceMag = cr * m_SRPArea;

            posPartials[0, 0] = reflectanceMag * incidentDirPosPartials[0, 0];
            posPartials[0, 1] = reflectanceMag * incidentDirPosPartials[0, 1];
            posPartials[0, 2] = reflectanceMag * incidentDirPosPartials[0, 2];

            posPartials[1, 0] = reflectanceMag * incidentDirPosPartials[1, 0];
            posPartials[1, 1] = reflectanceMag * incidentDirPosPartials[1, 1];
            posPartials[1, 2] = reflectanceMag * incidentDirPosPartials[1, 2];

            posPartials[2, 0] = reflectanceMag * incidentDirPosPartials[2, 0];
            posPartials[2, 1] = reflectanceMag * incidentDirPosPartials[2, 1];
            posPartials[2, 2] = reflectanceMag * incidentDirPosPartials[2, 2];

            ResultEval.SetReflectanceCompPosPartials((AgEUtFrame)frame,
                                                     posPartials[0, 0], posPartials[0, 1], posPartials[0, 2],
                                                     posPartials[1, 0], posPartials[1, 1], posPartials[1, 2],
                                                     posPartials[2, 0], posPartials[2, 1], posPartials[2, 2]);

            // VelPartials are zero in inertial - we'll set this anyway to test it

            bool doVelPartials = true;

            if (doVelPartials)
            {
                double[,] incidentDirVelPartials, velPartials;

                incidentDirVelPartials = new double[3, 3];
                velPartials            = new double[3, 3];;

                ResultEval.IncidentDirectionCompVelPartials((AgEUtFrame)frame,
                                                            ref incidentDirVelPartials[0, 0], ref incidentDirVelPartials[0, 1], ref incidentDirVelPartials[0, 2],
                                                            ref incidentDirVelPartials[1, 0], ref incidentDirVelPartials[1, 1], ref incidentDirVelPartials[1, 2],
                                                            ref incidentDirVelPartials[2, 0], ref incidentDirVelPartials[2, 1], ref incidentDirVelPartials[2, 2]);

                velPartials[0, 0] = reflectanceMag * incidentDirVelPartials[0, 0];
                velPartials[0, 1] = reflectanceMag * incidentDirVelPartials[0, 1];
                velPartials[0, 2] = reflectanceMag * incidentDirVelPartials[0, 2];

                velPartials[1, 0] = reflectanceMag * incidentDirVelPartials[1, 0];
                velPartials[1, 1] = reflectanceMag * incidentDirVelPartials[1, 1];
                velPartials[1, 2] = reflectanceMag * incidentDirVelPartials[1, 2];

                velPartials[2, 0] = reflectanceMag * incidentDirVelPartials[2, 0];
                velPartials[2, 1] = reflectanceMag * incidentDirVelPartials[2, 1];
                velPartials[2, 2] = reflectanceMag * incidentDirVelPartials[2, 2];

                ResultEval.SetReflectanceCompVelPartials((AgEUtFrame)frame,
                                                         velPartials[0, 0], velPartials[0, 1], velPartials[0, 2],
                                                         velPartials[1, 0], velPartials[1, 1], velPartials[1, 2],
                                                         velPartials[2, 0], velPartials[2, 1], velPartials[2, 2]);
            }

            Debug.WriteLine(m_MsgCntr + " " + cr + " : frame = Body : (" + incidentVec.x + "," + incidentVec.y + "," + incidentVec.z + ")");

            return(true);
        }
コード例 #3
0
        private void computeSRP(double illum, double cr, double solarFlux, Tuple3 pos,
                                Tuple3 vel, Tuple3 sunPos, ref Tuple3 sunlightSRP, ref Tuple3 sailingSRP)
        {
            //
            // Begin computation of SRP using the Pechenick model
            //

            // Compute some reference vectors

            Tuple3 w = new Tuple3();

            // compute unit_w
            crossProduct(pos, vel, ref w);
            normalize(ref w);

            // compute unit_r
            Tuple3 r = new Tuple3(pos);

            normalize(ref r);

            // compute unit_k
            Tuple3 k = new Tuple3(sunPos);
            double distance_SunToSat = normalize(ref k);

            k.scaleBy(-1.0);

            //DebugMsg("DistSun "+distance_SunToSat);
            //DebugMsg("k : ("+k.x+", "+k.y+", "+k.z+")");

            // compute unit_c
            Tuple3 c = new Tuple3();

            crossProduct(w, k, ref c);
            normalize(ref c);                   // unit vector in orbit plane in plane of solar array (c_hat)

            // compute unit_n
            Tuple3 n = new Tuple3();

            crossProduct(w, c, ref n);
            normalize(ref n);                   // unit vector in orbit plane normal to solar panel face towards sun
            // (solar panel faces sun_to_sat direction)

            //DebugMsg("n : ("+n.x+", "+n.y+", "+n.z+")");

            // compute unit_m
            Tuple3 m = new Tuple3(r);

            double dotP = dotProduct(r, k);

            if (dotP >= 0.0)
            {
                dotP = -1.0;
            }
            else
            {
                dotP = 1.0;
            }

            m.scaleBy(dotP);

            //DebugMsg("m : ("+m.x+", "+m.y+", "+m.z+")");

            Tuple3 temp = new Tuple3();                 // temp vector

            //compute k x (k x n)
            Tuple3 kkn = new Tuple3();

            crossProduct(k, n, ref temp);
            crossProduct(k, temp, ref kkn);

            //DebugMsg("kkn : ("+kkn.x+", "+kkn.y+", "+kkn.z+")");

            //compute k x (k x m)
            Tuple3 kkm = new Tuple3();

            crossProduct(k, m, ref temp);
            crossProduct(k, temp, ref kkm);

            //DebugMsg("kkm : ("+kkm.x+", "+kkm.y+", "+kkm.z+")");

            // compute angles

            double CosAlpha  = -1.0 * dotProduct(n, k);                 // n_hat and k_hat are almost anti-aligned
            double Cos2Alpha = 2.0 * CosAlpha * CosAlpha - 1.0;

            double CosAlphaStar  = -1.0 * dotProduct(m, k);
            double Cos2AlphaStar = 2.0 * CosAlphaStar * CosAlphaStar - 1.0;

            //DebugMsg("Cos(alpha) = "+CosAlpha+", Cos(alphaStar) = "+cosAlphaStar);

            // compute some aux qtys

            // NOTE: we are using the formulas here with the app providing Luminosity (thru the solar flux value),
            //		Mass, Cr, spacecraft mass, speed of light. Thus, the value for B_tilde_P_i and C_tilde
            //		from the paper will be computed on the fly, rather than being assumed constant
            //
            //		Also, there is a typo in formula (3.1) on page 5: in that formula, r
            //		means magnitude(sun_to_Sat_vector)

            // NOTE: Cr is applied only to the k direction, not kkn nor kkm

            double C_Term     = cr * illum * solarFlux * (m_BusTerm + 2 * m_SA_Term);
            double B_P_1_Term = illum * solarFlux * m_BP1Term;
            double B_P_2_Term = illum * solarFlux * m_BP2Term;
            double tempVal;

            // compute sailing srp contributions

            tempVal = B_P_1_Term * CosAlpha * (2.0 + m_SpecularReflectivity * (6.0 * CosAlpha - 2.0));

            Tuple3 B_P_1_Term_Contrib_kkn = new Tuple3(kkn);

            B_P_1_Term_Contrib_kkn.scaleBy(tempVal);

            tempVal = B_P_2_Term * CosAlphaStar * (2.0 + m_SpecularReflectivity * (6.0 * CosAlphaStar - 2.0));

            Tuple3 B_P_2_Term_Contrib_kkm = new Tuple3(kkm);

            B_P_2_Term_Contrib_kkm.scaleBy(tempVal);

            sailingSRP.scaleBy(0.0);
            sailingSRP.addTo(B_P_1_Term_Contrib_kkn);
            sailingSRP.addTo(B_P_2_Term_Contrib_kkm);

            DebugMsg("Sailing SRP = (" + sailingSRP.x + ", " + sailingSRP.y + ", " + sailingSRP.z + ")");

            // compute sunlight srp contributions

            Tuple3 C_Term_Contrib = new Tuple3(k);

            C_Term_Contrib.scaleBy(C_Term);

            tempVal = cr * B_P_1_Term * CosAlpha * ((3.0 + 2.0 * CosAlpha) +
                                                    m_SpecularReflectivity * (3.0 * Cos2Alpha - 2.0 * CosAlpha));

            Tuple3 B_P_1_Term_Contrib_k = new Tuple3(k);

            B_P_1_Term_Contrib_k.scaleBy(tempVal);

            tempVal = cr * B_P_2_Term * CosAlphaStar * ((3.0 + 2.0 * CosAlphaStar) +
                                                        m_SpecularReflectivity * (3.0 * Cos2AlphaStar - 2.0 * CosAlphaStar));

            Tuple3 B_P_2_Term_Contrib_k = new Tuple3(k);

            B_P_2_Term_Contrib_k.scaleBy(tempVal);

            sunlightSRP.scaleBy(0.0);
            sunlightSRP.addTo(C_Term_Contrib);
            sunlightSRP.addTo(B_P_1_Term_Contrib_k);
            sunlightSRP.addTo(B_P_2_Term_Contrib_k);

            DebugMsg("Sunlight SRP = (" + sunlightSRP.x + ", " + sunlightSRP.y + ", " + sunlightSRP.z + ")");
        }