• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PegasusSolver类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中org.apache.commons.math3.analysis.solvers.PegasusSolver的典型用法代码示例。如果您正苦于以下问题:Java PegasusSolver类的具体用法?Java PegasusSolver怎么用?Java PegasusSolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

PegasusSolver类属于org.apache.commons.math3.analysis.solvers包,在下文中一共展示了PegasusSolver类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: test

点赞 2

import org.apache.commons.math3.analysis.solvers.PegasusSolver; //导入依赖的package包/类
public double test(int integratorType)
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = (integratorType == 1)
                 ? new DormandPrince853Integrator(e, 100.0, 1e-7, 1e-7)
                 : new GraggBulirschStoerIntegrator(e, 100.0, 1e-7, 1e-7);
    PegasusSolver rootSolver = new PegasusSolver(e, e);
    integrator.addEventHandler(new Event(), 0.1, e, 1000, rootSolver);
    double t0 = 6.0;
    double tEnd = 10.0;
    double[] y = {2.0, 2.0, 2.0, 4.0, 2.0, 7.0, 15.0};
    return integrator.integrate(new Ode(), t0, y, tEnd, y);
}
 

开发者ID:Quanticol,
项目名称:CARMA,
代码行数:16,
代码来源:ReappearingEventTest.java

示例2: test

点赞 2

import org.apache.commons.math3.analysis.solvers.PegasusSolver; //导入依赖的package包/类
/** Test for events that occur at the exact same time, but due to numerical
 * calculations occur very close together instead.
 * @param eventType the type of events to use. See
 * {@link org.apache.commons.math3.ode.events.EventHandler#g(double, double[])
 * EventHandler.g(double, double[])}.
 */
public void test(int eventType)
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator = new DormandPrince853Integrator(e, 100.0, 1e-7, 1e-7);
    BaseSecantSolver rootSolver = new PegasusSolver(e, e);
    EventHandler evt1 = new Event(0, eventType);
    EventHandler evt2 = new Event(1, eventType);
    integrator.addEventHandler(evt1, 0.1, e, 999, rootSolver);
    integrator.addEventHandler(evt2, 0.1, e, 999, rootSolver);
    double t = 0.0;
    double tEnd = 10.0;
    double[] y = {0.0, 0.0};
    List<Double> events1 = new ArrayList<Double>();
    List<Double> events2 = new ArrayList<Double>();
    while (t < tEnd) {
        t = integrator.integrate(this, t, y, tEnd, y);
        //System.out.println("t=" + t + ",\t\ty=[" + y[0] + "," + y[1] + "]");

        if (y[0] >= 1.0) {
            y[0] = 0.0;
            events1.add(t);
            //System.out.println("Event 1 @ t=" + t);
        }
        if (y[1] >= 1.0) {
            y[1] = 0.0;
            events2.add(t);
            //System.out.println("Event 2 @ t=" + t);
        }
    }
    Assert.assertEquals(EVENT_TIMES1.length, events1.size());
    Assert.assertEquals(EVENT_TIMES2.length, events2.size());
    for(int i = 0; i < EVENT_TIMES1.length; i++) {
        Assert.assertEquals(EVENT_TIMES1[i], events1.get(i), 1e-7);
    }
    for(int i = 0; i < EVENT_TIMES2.length; i++) {
        Assert.assertEquals(EVENT_TIMES2[i], events2.get(i), 1e-7);
    }
    //System.out.println();
}
 

开发者ID:Quanticol,
项目名称:CARMA,
代码行数:47,
代码来源:OverlappingEventsTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)