use of org.hipparchus.analysis.differentiation.DerivativeStructure in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraft method facetRadiationAcceleration.
/**
* Compute contribution of one facet to force.
* <p>This method implements equation 8-44 from David A. Vallado's
* Fundamentals of Astrodynamics and Applications, third edition,
* 2007, Microcosm Press.</p>
* @param normal facet normal
* @param area facet area
* @param fluxSat radiation pressure flux in spacecraft frame
* @param dot dot product of facet and fluxSat (must be negative)
* @param specularReflectionCoeffDS specular reflection coefficient
* @param diffuseReflectionCoeffDS diffuse reflection coefficient
* @return contribution of the facet to force in spacecraft frame
*/
private FieldVector3D<DerivativeStructure> facetRadiationAcceleration(final Vector3D normal, final double area, final Vector3D fluxSat, final double dot, final DerivativeStructure specularReflectionCoeffDS, final DerivativeStructure diffuseReflectionCoeffDS) {
final double psr = fluxSat.getNorm();
// Vallado's equation 8-44 uses different parameters which are related to our parameters as:
// cos (phi) = -dot / (psr * area)
// n = facet / area
// s = -fluxSat / psr
final DerivativeStructure cN = diffuseReflectionCoeffDS.divide(3).subtract(specularReflectionCoeffDS.multiply(dot / psr)).multiply(2 * area * dot);
final DerivativeStructure cS = specularReflectionCoeffDS.subtract(1).multiply(area * dot / psr);
return new FieldVector3D<>(cN, normal, cS, fluxSat);
}
use of org.hipparchus.analysis.differentiation.DerivativeStructure in project Orekit by CS-SI.
the class DragForce method isStateDerivative.
/**
* Check if a field state corresponds to derivatives with respect to state.
* @param state state to check
* @param <T> type of the field elements
* @return true if state corresponds to derivatives with respect to state
* @since 9.0
*/
private <T extends RealFieldElement<T>> boolean isStateDerivative(final FieldSpacecraftState<T> state) {
try {
final DerivativeStructure dsMass = (DerivativeStructure) state.getMass();
final int o = dsMass.getOrder();
final int p = dsMass.getFreeParameters();
// Number of parameters must be 6 (PV), 7 (PV + drag coefficient) or 8 (PV + drag coefficient + lift ratio)
if (o != 1 || (p != 6 && p != 7 && p != 8)) {
return false;
}
// Check that the first 6 parameters are position and velocity
@SuppressWarnings("unchecked") final FieldPVCoordinates<DerivativeStructure> pv = (FieldPVCoordinates<DerivativeStructure>) state.getPVCoordinates();
return isVariable(pv.getPosition().getX(), 0) && isVariable(pv.getPosition().getY(), 1) && isVariable(pv.getPosition().getZ(), 2) && isVariable(pv.getVelocity().getX(), 3) && isVariable(pv.getVelocity().getY(), 4) && isVariable(pv.getVelocity().getZ(), 5);
} catch (ClassCastException cce) {
return false;
}
}
use of org.hipparchus.analysis.differentiation.DerivativeStructure in project Orekit by CS-SI.
the class HolmesFeatherstoneAttractionModel method acceleration.
/**
* {@inheritDoc}
*/
public <T extends RealFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s, final T[] parameters) throws OrekitException {
final T mu = parameters[0];
// check for faster computation dedicated to derivatives with respect to state
if (isStateDerivative(s)) {
@SuppressWarnings("unchecked") final FieldVector3D<DerivativeStructure> p = (FieldVector3D<DerivativeStructure>) s.getPVCoordinates().getPosition();
@SuppressWarnings("unchecked") final FieldVector3D<T> a = (FieldVector3D<T>) accelerationWrtState(s.getDate().toAbsoluteDate(), s.getFrame(), p, (DerivativeStructure) mu);
return a;
}
// get the position in body frame
final FieldAbsoluteDate<T> date = s.getDate();
final Transform fromBodyFrame = bodyFrame.getTransformTo(s.getFrame(), date.toAbsoluteDate());
final Transform toBodyFrame = fromBodyFrame.getInverse();
final FieldVector3D<T> position = toBodyFrame.transformPosition(s.getPVCoordinates().getPosition());
// gradient of the non-central part of the gravity field
return fromBodyFrame.transformVector(new FieldVector3D<>(gradient(date, position, mu)));
}
use of org.hipparchus.analysis.differentiation.DerivativeStructure in project Orekit by CS-SI.
the class IsotropicRadiationClassicalConvention method radiationPressureAcceleration.
/**
* {@inheritDoc}
*/
@Override
public FieldVector3D<DerivativeStructure> radiationPressureAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position, final Rotation rotation, final double mass, final Vector3D flux, final double[] parameters, final String paramName) throws OrekitException {
final DerivativeStructure caDS;
final DerivativeStructure csDS;
if (ABSORPTION_COEFFICIENT.equals(paramName)) {
caDS = factory.variable(0, parameters[0]);
csDS = factory.constant(parameters[1]);
} else if (REFLECTION_COEFFICIENT.equals(paramName)) {
caDS = factory.constant(parameters[0]);
csDS = factory.variable(0, parameters[1]);
} else {
throw new OrekitException(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, paramName, ABSORPTION_COEFFICIENT + ", " + REFLECTION_COEFFICIENT);
}
final DerivativeStructure kP = caDS.add(csDS).subtract(1).multiply(-4.0 / 9.0).add(1).multiply(crossSection);
return new FieldVector3D<>(kP.divide(mass), flux);
}
use of org.hipparchus.analysis.differentiation.DerivativeStructure in project Orekit by CS-SI.
the class HansenTesseralLinear method computeInitValues.
/**
* Compute the values for the first four coefficients and their derivatives by means of series.
*
* @param e2 e²
* @param chi Χ
* @param chi2 Χ²
*/
public void computeInitValues(final double e2, final double chi, final double chi2) {
// compute the values for n, n+1, n+2 and n+3 by series
// See Danielson 2.7.3-(10)
// Ensure that only the needed terms are computed
final int maxRoots = FastMath.min(4, N0 - Nmin + 4);
for (int i = 0; i < maxRoots; i++) {
final DerivativeStructure hansenKernel = hansenInit[i].getValue(e2, chi, chi2);
this.hansenRoot[0][i] = hansenKernel.getValue();
this.hansenDerivRoot[0][i] = hansenKernel.getPartialDerivative(1);
}
for (int i = 1; i < numSlices; i++) {
for (int k = 0; k < 4; k++) {
final PolynomialFunction[] mv = mpvec[N0 - (i * SLICE) - k + 3 + offset];
final PolynomialFunction[] sv = mpvecDeriv[N0 - (i * SLICE) - k + 3 + offset];
hansenDerivRoot[i][k] = mv[3].value(chi) * hansenDerivRoot[i - 1][3] + mv[2].value(chi) * hansenDerivRoot[i - 1][2] + mv[1].value(chi) * hansenDerivRoot[i - 1][1] + mv[0].value(chi) * hansenDerivRoot[i - 1][0] + sv[3].value(chi) * hansenRoot[i - 1][3] + sv[2].value(chi) * hansenRoot[i - 1][2] + sv[1].value(chi) * hansenRoot[i - 1][1] + sv[0].value(chi) * hansenRoot[i - 1][0];
hansenRoot[i][k] = mv[3].value(chi) * hansenRoot[i - 1][3] + mv[2].value(chi) * hansenRoot[i - 1][2] + mv[1].value(chi) * hansenRoot[i - 1][1] + mv[0].value(chi) * hansenRoot[i - 1][0];
}
}
}
Aggregations