1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.commons.math4.legacy.ode; 19 20 import org.apache.commons.math4.legacy.core.RealFieldElement; 21 import org.apache.commons.math4.legacy.exception.DimensionMismatchException; 22 import org.apache.commons.math4.legacy.exception.MaxCountExceededException; 23 24 /** 25 * This interface allows users to add secondary differential equations to a primary 26 * set of differential equations. 27 * <p> 28 * In some cases users may need to integrate some problem-specific equations along 29 * with a primary set of differential equations. One example is optimal control where 30 * adjoined parameters linked to the minimized Hamiltonian must be integrated. 31 * </p> 32 * <p> 33 * This interface allows users to add such equations to a primary set of {@link 34 * FirstOrderFieldDifferentialEquations first order differential equations} 35 * thanks to the {@link FieldExpandableODE#addSecondaryEquations(FieldSecondaryEquations)} 36 * method. 37 * </p> 38 * @see FirstOrderFieldDifferentialEquations 39 * @see FieldExpandableODE 40 * @param <T> the type of the field elements 41 * @since 3.6 42 */ 43 public interface FieldSecondaryEquations<T extends RealFieldElement<T>> { 44 45 /** Get the dimension of the secondary state parameters. 46 * @return dimension of the secondary state parameters 47 */ 48 int getDimension(); 49 50 /** Initialize equations at the start of an ODE integration. 51 * <p> 52 * This method is called once at the start of the integration. It 53 * may be used by the equations to initialize some internal data 54 * if needed. 55 * </p> 56 * @param t0 value of the independent <I>time</I> variable at integration start 57 * @param primary0 array containing the value of the primary state vector at integration start 58 * @param secondary0 array containing the value of the secondary state vector at integration start 59 * @param finalTime target time for the integration 60 */ 61 void init(T t0, T[] primary0, T[] secondary0, T finalTime); 62 63 /** Compute the derivatives related to the secondary state parameters. 64 * @param t current value of the independent <I>time</I> variable 65 * @param primary array containing the current value of the primary state vector 66 * @param primaryDot array containing the derivative of the primary state vector 67 * @param secondary array containing the current value of the secondary state vector 68 * @return derivative of the secondary state vector 69 * @exception MaxCountExceededException if the number of functions evaluations is exceeded 70 * @exception DimensionMismatchException if arrays dimensions do not match equations settings 71 */ 72 T[] computeDerivatives(T t, T[] primary, T[] primaryDot, T[] secondary) 73 throws MaxCountExceededException, DimensionMismatchException; 74 }