public bool Evaluate(AgAsDragModelResultEval ResultEval) { _MsgCntr++; if (_Enabled && (ResultEval != null)) { double cd = 0.0; double cl = 0.0; if (_CDIndex > -1) { cd = ResultEval.ParameterValue(_CDIndex); } if (_CDIndex > -1) { cl = ResultEval.ParameterValue(_CLIndex); } if (_MsgCntr % 1000 == 0) { if (_trueAnomScalar != null) { double val = 0.0; if (_trueAnomScalar.CurrentValue(ResultEval, ref val)) { DebugMessage(AgEUtLogMsgType.eUtLogMsgInfo, "TrueAnomaly: (" + val.ToString() + ")"); } else { Message(AgEUtLogMsgType.eUtLogMsgWarning, "TrueAnomaly calcscalar value could not be obtained."); } } if (_posVec != null) { double X = 0.0, Y = 0.0, Z = 0.0; if (_posVec.CurrentValue(ResultEval, ref X, ref Y, ref Z)) { DebugMessage(AgEUtLogMsgType.eUtLogMsgInfo, "Position: (" + X.ToString() + ", " + Y.ToString() + ", " + Z.ToString() + ")"); } else { Message(AgEUtLogMsgType.eUtLogMsgWarning, "Position vector values could not be obtained."); } } } SetDragLiftReflectanceInFixed(ResultEval, cd, cl); } return(_Enabled); }
private bool SetDragLiftReflectanceInFixed(AgAsDragModelResultEval result, double cd, double cl) { bool returnValue = false; Array incidentVecFixed = result.IncidentDirection_Array(AgEUtFrame.eUtFrameFixed); Array posParts = Array.CreateInstance(typeof(Object), 9); posParts.SetValue(0.0, 0); posParts.SetValue(0.0, 1); posParts.SetValue(0.0, 2); posParts.SetValue(0.0, 3); posParts.SetValue(0.0, 4); posParts.SetValue(0.0, 5); posParts.SetValue(0.0, 6); posParts.SetValue(0.0, 7); posParts.SetValue(0.0, 8); Array velParts = Array.CreateInstance(typeof(Object), 9); velParts.SetValue(0.0, 0); velParts.SetValue(0.0, 1); velParts.SetValue(0.0, 2); velParts.SetValue(0.0, 3); velParts.SetValue(0.0, 4); velParts.SetValue(0.0, 5); velParts.SetValue(0.0, 6); velParts.SetValue(0.0, 7); velParts.SetValue(0.0, 8); if (incidentVecFixed != null) { // particle reflectance is positive along the incidence vector // and the incidence vector is opposite the fixed velocity. double x = _DragArea * (double)incidentVecFixed.GetValue(0); double y = _DragArea * (double)incidentVecFixed.GetValue(1); double z = _DragArea * (double)incidentVecFixed.GetValue(2); if (_CDIndex > -1) { // printf DEBUGFILE "CD partials: %20.15e, %20.15e, %20.15e\n", $x, $y, $z; result.SetReflectanceParamPartials(_CDIndex, AgEUtFrame.eUtFrameFixed, x, y, z); } x *= cd; y *= cd; z *= cd; // Compute the direction of Lift Array pvFixedArray = result.PosVel_Array(AgEUtFrame.eUtFrameFixed); Array crossTrackArray = CrossProduct(pvFixedArray, incidentVecFixed); Normalize(crossTrackArray); Array liftDirFixed = CrossProduct(crossTrackArray, incidentVecFixed); double xL = _LiftArea * (double)liftDirFixed.GetValue(0); double yL = _LiftArea * (double)liftDirFixed.GetValue(1); double zL = _LiftArea * (double)liftDirFixed.GetValue(2); if (_CLIndex > -1) { //printf DEBUGFILE "PV: %20.15e, %20.15e, %20.15e\n", $pvFixedArray->[0], $pvFixedArray->[1], $pvFixedArray->[2]; //printf DEBUGFILE "Lift dir: %20.15e, %20.15e, %20.15e\n", $liftDirFixed->[0], $liftDirFixed->[1], $liftDirFixed->[2]; //printf DEBUGFILE "Xtrack dir: %20.15e, %20.15e, %20.15e\n", $crossTrackArray->[0], $crossTrackArray->[1], $crossTrackArray->[2]; //printf DEBUGFILE "Lift area: %20.15e\n", $m_LiftArea; //printf DEBUGFILE "CL partials: %20.15e, %20.15e, %20.15e\n", $xL, $yL, $zL; //printf DEBUGFILE "CL index: %2d\n", $m_CLIndex; result.SetReflectanceParamPartials(_CLIndex, AgEUtFrame.eUtFrameFixed, xL, yL, zL); } xL *= cl; yL *= cl; zL *= cl; x += xL; y += yL; z += zL; //#printf DEBUGFILE "Cd: %10.3f\nIncidence: %20.15e %20.15e %20.15e \n", // # $cd, $incidentVecFixed->[0], $incidentVecFixed->[1], $incidentVecFixed->[2]; //#printf DEBUGFILE "Cl: %10.3f\nLift: %20.15e %20.15e %20.15e \n", // # $cd, $liftDirFixed->[0], $liftDirFixed->[1], $liftDirFixed->[2]; result.SetReflectance(AgEUtFrame.eUtFrameFixed, x, y, z); //printf DEBUGFILE "reflectance: %20.15e, %20.15e, %20.15e\n", $x, $y, $z; Array incidentDirPosPartialsArrayFixed = result.IncidentDirectionCompPosPartials_Array(AgEUtFrame.eUtFrameFixed); if (incidentDirPosPartialsArrayFixed != null) { //# writeMatrix($incidentDirPosPartialsArrayFixed, "IncFixedPPs"); // Position partials double BCoeff = cd * _DragArea; for (int k = 0; k < 9; k++) { posParts.SetValue(BCoeff * (double)incidentDirPosPartialsArrayFixed.GetValue(k), k); } result.SetReflectanceCompPosPartials(AgEUtFrame.eUtFrameFixed, (double)posParts.GetValue(0), (double)posParts.GetValue(1), (double)posParts.GetValue(2), (double)posParts.GetValue(3), (double)posParts.GetValue(4), (double)posParts.GetValue(5), (double)posParts.GetValue(6), (double)posParts.GetValue(7), (double)posParts.GetValue(8)); //# writeMatrix(\@posParts, "OutFixedPPs"); // Velocity partials Array incidentDirVelPartialsArrayFixed = result.IncidentDirectionCompVelPartials_Array(AgEUtFrame.eUtFrameFixed); if (incidentDirVelPartialsArrayFixed != null) { //# writeMatrix($incidentDirVelPartialsArrayFixed, "IncFixedVPs"); for (int k = 0; k < 9; k++) { velParts.SetValue(BCoeff * (double)incidentDirVelPartialsArrayFixed.GetValue(k), k); } result.SetReflectanceCompVelPartials(AgEUtFrame.eUtFrameFixed, (double)velParts.GetValue(0), (double)velParts.GetValue(1), (double)velParts.GetValue(2), (double)velParts.GetValue(3), (double)velParts.GetValue(4), (double)velParts.GetValue(5), (double)velParts.GetValue(6), (double)velParts.GetValue(7), (double)velParts.GetValue(8)); //#writeMatrix(\@velParts, "OutFixedVPs"); } //my $tempStr = "$m_MsgCntr> $cd $cl: ($x, $y, $z)"; //DebugMsg($tempStr); returnValue = true; } } return(returnValue); }