예제 #1
0
        public Fdm1DimSolver(FdmSolverDesc solverDesc,
                             FdmSchemeDesc schemeDesc,
                             FdmLinearOpComposite op)
        {
            solverDesc_     = solverDesc;
            schemeDesc_     = schemeDesc;
            op_             = op;
            thetaCondition_ = new FdmSnapshotCondition(
                0.99 * Math.Min(1.0 / 365.0,
                                solverDesc.condition.stoppingTimes().empty()
                            ? solverDesc.maturity
                            : solverDesc.condition.stoppingTimes().First()));

            conditions_ = FdmStepConditionComposite.joinConditions(thetaCondition_,
                                                                   solverDesc.condition);
            x_             = new InitializedList <double>(solverDesc.mesher.layout().size());
            initialValues_ = new InitializedList <double>(solverDesc.mesher.layout().size());
            resultValues_  = new Vector(solverDesc.mesher.layout().size());

            FdmMesher         mesher = solverDesc.mesher;
            FdmLinearOpLayout layout = mesher.layout();

            FdmLinearOpIterator endIter = layout.end();

            for (FdmLinearOpIterator iter = layout.begin(); iter != endIter;
                 ++iter)
            {
                initialValues_[iter.index()]
                    = solverDesc_.calculator.avgInnerValue(iter,
                                                           solverDesc.maturity);
                x_[iter.index()] = mesher.location(iter, 0);
            }
        }
예제 #2
0
 public ExplicitEulerScheme(FdmLinearOpComposite map,
                            List <BoundaryCondition <FdmLinearOp> > bcSet = null)
 {
     dt_    = null;
     map_   = map;
     bcSet_ = new BoundaryConditionSchemeHelper(bcSet);
 }
예제 #3
0
 public DouglasScheme(double theta,
                      FdmLinearOpComposite map,
                      List <BoundaryCondition <FdmLinearOp> > bcSet = null)
 {
     dt_    = null;
     theta_ = theta;
     map_   = map;
     bcSet_ = new BoundaryConditionSchemeHelper(bcSet);
 }
 public ModifiedCraigSneydScheme(double theta, double mu,
                                 FdmLinearOpComposite map,
                                 List <BoundaryCondition <FdmLinearOp> > bcSet = null)
 {
     dt_    = null;
     theta_ = theta;
     mu_    = mu;
     map_   = map;
     bcSet_ = new BoundaryConditionSchemeHelper(bcSet);
 }
예제 #5
0
 public FdmBackwardSolver(FdmLinearOpComposite map,
                          FdmBoundaryConditionSet bcSet,
                          FdmStepConditionComposite condition,
                          FdmSchemeDesc schemeDesc)
 {
     map_        = map;
     bcSet_      = bcSet;
     condition_  = condition;
     schemeDesc_ = schemeDesc;
 }
예제 #6
0
 public MethodOfLinesScheme(double eps,
                            double relInitStepSize,
                            FdmLinearOpComposite map,
                            List <BoundaryCondition <FdmLinearOp> > bcSet = null)
 {
     dt_              = null;
     eps_             = eps;
     relInitStepSize_ = relInitStepSize;
     map_             = map;
     bcSet_           = new BoundaryConditionSchemeHelper(bcSet);
 }
예제 #7
0
 public CrankNicolsonScheme(double theta,
                            FdmLinearOpComposite map,
                            List <BoundaryCondition <FdmLinearOp> > bcSet = null,
                            double relTol = 1E-8,
                            ImplicitEulerScheme.SolverType solverType = ImplicitEulerScheme.SolverType.BiCGstab)
 {
     dt_       = null;
     theta_    = theta;
     explicit_ = new ExplicitEulerScheme(map, bcSet);
     implicit_ = new ImplicitEulerScheme(map, bcSet, relTol, solverType);
 }
예제 #8
0
 public ImplicitEulerScheme(FdmLinearOpComposite map,
                            List <BoundaryCondition <FdmLinearOp> > bcSet,
                            double relTol         = 1e-8,
                            SolverType solverType = SolverType.BiCGstab)
 {
     dt_         = null;
     iterations_ = 0;
     relTol_     = relTol;
     map_        = map;
     bcSet_      = new BoundaryConditionSchemeHelper(bcSet);
     solverType_ = solverType;
 }
예제 #9
0
 public TrBDF2Scheme(double alpha,
                     FdmLinearOpComposite map,
                     TrapezoidalScheme trapezoidalScheme,
                     List <BoundaryCondition <FdmLinearOp> > bcSet = null,
                     double relTol = 1E-8,
                     TrBDF2Scheme <TrapezoidalScheme> .SolverType solverType = TrBDF2Scheme <TrapezoidalScheme> .SolverType.BiCGstab)
 {
     dt_                = null;
     beta_              = null;
     iterations_        = 0;
     alpha_             = alpha;
     map_               = map;
     trapezoidalScheme_ = trapezoidalScheme;
     bcSet_             = new BoundaryConditionSchemeHelper(bcSet);
     relTol_            = relTol;
     solverType_        = solverType;
 }