Coverage for C:\src\imod-python\imod\mf6\ims.py: 89%

46 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-13 11:15 +0200

1import numpy as np 

2import xarray as xr 

3 

4from imod.logging import init_log_decorator 

5from imod.mf6.package import Package 

6from imod.schemata import AllValueSchema, DTypeSchema, OptionSchema 

7 

8 

9class Solution(Package): 

10 """ 

11 Iterative Model Solution. 

12 The model solution will solve all of the models that are added to it, as 

13 specified in the simulation name file, and will include Numerical Exchanges, 

14 if they are present. The iterative model solution requires specification of 

15 both nonlinear and linear settings. 

16 https://water.usgs.gov/water-resources/software/MODFLOW-6/mf6io_6.0.4.pdf#page=147 

17 

18 Three predifined solutions settings are available: SolutionPresetSimple, 

19 SolutionPresetModerate and SolutionPresetComplex. When using one of the 

20 predefined solutions only the print_option, csv_output, and no_ptc have to 

21 be defined. The default values for each are described below. 

22 

23 Parameters 

24 ---------- 

25 modelnames: list of str 

26 Which models to solve in this solution. Only models of the same type 

27 (GWF or GWT) should be added to the same solution. 

28 outer_dvclose: float 

29 real value defining the head change criterion for convergence of the 

30 outer (nonlinear) iterations, in units of length. When the maximum 

31 absolute value of the head change at all nodes during an iteration is 

32 less than or equal to outer_dvclose, iteration stops. Commonly, 

33 outer_dvclose equals 0.01. 

34 SolutionPresetSimple: 0.001 

35 SolutionPresetModerate: 0.01 

36 SolutionPresetComplex: 0.1 

37 outer_maximum: int 

38 integer value defining the maximum number of outer (nonlinear) 

39 iterations - that is, calls to the solution routine. For a linear 

40 problem outer_maximum should be 1. 

41 SolutionPresetSimple: 25 

42 SolutionPresetModerate: 50 

43 SolutionPresetComplex: 100 

44 inner_maximum: int 

45 integer value defining the maximum number of inner (linear) iterations. 

46 The number typically depends on the characteristics of the matrix 

47 solution scheme being used. For nonlinear problems, inner_maximum 

48 usually ranges from 60 to 600; a value of 100 will be sufficient for 

49 most linear problems. 

50 SolutionPresetSimple: 50 

51 SolutionPresetModerate: 100 

52 SolutionPresetComplex: 500 

53 inner_dvclose: float 

54 real value defining the head change criterion for convergence of the 

55 inner (linear) iterations, in units of length. When the maximum absolute 

56 value of the head change at all nodes during an iteration is less than 

57 or equal to inner_dvclose, the matrix solver assumes convergence. 

58 Commonly, inner_dvclose is set an order of magnitude less than the 

59 outer_dvclose value. 

60 SolutionPresetSimple: 0.001 

61 SolutionPresetModerate: 0.01 

62 SolutionPresetComplex: 0.1 

63 inner_rclose: float 

64 real value that defines the flow residual tolerance for convergence of 

65 the IMS linear solver and specific flow residual criteria used. This 

66 value represents the maximum allowable residual at any single node. 

67 Value is in units of length cubed per time, and must be consistent with 

68 MODFLOW 6 length and time units. Usually a value of 1.0 × 10−1 is 

69 sufficient for the flow-residual criteria when meters and seconds are 

70 the defined MODFLOW 6 length and time. 

71 SolutionPresetSimple: 0.1 

72 SolutionPresetModerate: 0.1 

73 SolutionPresetComplex: 0.1 

74 linear_acceleration: str 

75 options: {"cg", "bicgstab"} 

76 a keyword that defines the linear acceleration method used by the 

77 default IMS linear solvers. CG - preconditioned conjugate gradient 

78 method. BICGSTAB - preconditioned bi-conjugate gradient stabilized 

79 method. 

80 SolutionPresetSimple: "cg" 

81 SolutionPresetModerate: "bicgstab" 

82 SolutionPresetComplex: "bicgstab" 

83 under_relaxation: str, optional 

84 options: {None, "simple", "cooley", "dbd"} 

85 is an optional keyword that defines the nonlinear relative_rclose 

86 schemes used. By default under_relaxation is not used. 

87 None - relative_rclose is not used. 

88 simple - Simple relative_rclose scheme with a fixed relaxation factor is 

89 used. 

90 cooley - Cooley relative_rclose scheme is used. 

91 dbd - delta-bar-delta relative_rclose is used. 

92 Note that the relative_rclose schemes are used in conjunction with 

93 problems that use the Newton-Raphson formulation, however, experience 

94 has indicated that the Cooley relative_rclose and damping work well also 

95 for the Picard scheme with the wet/dry options of MODFLOW 6. 

96 Default value: None 

97 SolutionPresetSimple: None 

98 SolutionPresetModerate: "dbd" 

99 SolutionPresetComplex: "dbd" 

100 under_relaxation_theta: float, optional 

101 real value defining the reduction factor for the learning rate 

102 (underrelaxation term) of the delta-bar-delta algorithm. The value of 

103 under relaxation theta is between zero and one. If the change in the 

104 variable (head) is of opposite sign to that of the previous iteration, 

105 the relative_rclose term is reduced by a factor of under relaxation 

106 theta. The value usually ranges from 0.3 to 0.9; a value of 0.7 works 

107 well for most problems. under relaxation theta only needs to be 

108 specified if under relaxation is dbd. 

109 Default value: None 

110 SolutionPresetSimple: 0.0 

111 SolutionPresetModerate: 0.9 

112 SolutionPresetComplex: 0.8 

113 under_relaxation_kappa: float, optional 

114 real value defining the increment for the learning rate (relative_rclose 

115 term) of the delta-bar-delta algorithm. The value of under relaxation 

116 kappa is between zero and one. If the change in the variable (head) is 

117 of the same sign to that of the previous iteration, the relative_rclose 

118 term is increased by an increment of under_relaxation_kappa. The value 

119 usually ranges from 0.03 to 0.3; a value of 0.1 works well for most 

120 problems. under relaxation kappa only needs to be specified if under 

121 relaxation is dbd. 

122 Default value: None 

123 SolutionPresetSimple: 0.0 

124 SolutionPresetModerate: 0.0001 

125 SolutionPresetComplex: 0.0001 

126 under_relaxation_gamma: float, optional 

127 real value defining the history or memory term factor of the 

128 delta-bardelta algorithm. under relaxation gamma is between zero and 1 

129 but cannot be equal to one. When under relaxation gamma is zero, only 

130 the most recent history (previous iteration value) is maintained. As 

131 under relaxation gamma is increased, past history of iteration changes 

132 has greater influence on the memory term. The memory term is maintained 

133 as an exponential average of past changes. Retaining some past history 

134 can overcome granular behavior in the calculated function surface and 

135 therefore helps to overcome cyclic patterns of nonconvergence. The value 

136 usually ranges from 0.1 to 0.3; a value of 0.2 works well for most 

137 problems. under relaxation gamma only needs to be specified if under 

138 relaxation is not none. 

139 Default value: None 

140 SolutionPresetSimple: 0.0 

141 SolutionPresetModerate: 0.0 

142 SolutionPresetComplex: 0.0 

143 under_relaxation_momentum: float, optional 

144 real value defining the fraction of past history changes that is added 

145 as a momentum term to the step change for a nonlinear iteration. The 

146 value of under relaxation momentum is between zero and one. A large 

147 momentum term should only be used when small learning rates are 

148 expected. Small amounts of the momentum term help convergence. The value 

149 usually ranges from 0.0001 to 0.1; a value of 0.001 works well for most 

150 problems. under relaxation momentum only needs to be specified if under 

151 relaxation is dbd. 

152 Default value: None 

153 SolutionPresetSimple: 0.0 

154 SolutionPresetModerate: 0.0 

155 SolutionPresetComplex: 0.0 

156 backtracking_number: int, optional 

157 integer value defining the maximum number of backtracking iterations 

158 allowed for residual reduction computations. If backtracking number = 0 

159 then the backtracking iterations are omitted. The value usually ranges 

160 from 2 to 20; a value of 10 works well for most problems. 

161 Default value: None 

162 SolutionPresetSimple: 0 

163 SolutionPresetModerate: 0 

164 SolutionPresetComplex: 20 

165 backtracking_tolerance: float, optional 

166 real value defining the tolerance for residual change that is allowed 

167 for residual reduction computations. backtracking tolerance should not 

168 be less than one to avoid getting stuck in local minima. A large value 

169 serves to check for extreme residual increases, while a low value serves 

170 to control step size more severely. The value usually ranges from 1.0 to 

171 106; a value of 104 works well for most problems but lower values like 

172 1.1 may be required for harder problems. backtracking tolerance only 

173 needs to be specified if backtracking_number is greater than zero. 

174 Default value: None 

175 SolutionPresetSimple: 0.0 

176 SolutionPresetModerate: 0.0 

177 SolutionPresetComplex: 1.05 

178 backtracking_reduction_factor: float, optional 

179 real value defining the reduction in step size used for residual 

180 reduction computations. The value of backtracking reduction factor is 

181 between 142 MODFLOW 6 - Description of Input and Output zero and one. 

182 The value usually ranges from 0.1 to 0.3; a value of 0.2 works well for 

183 most problems. backtracking_reduction_factor only needs to be specified 

184 if backtracking number is greater than zero. 

185 Default value: None 

186 SolutionPresetSimple: 0.0 

187 SolutionPresetModerate: 0.0 

188 SolutionPresetComplex: 0.1 

189 backtracking_residual_limit: float, optional 

190 real value defining the limit to which the residual is reduced with 

191 backtracking. If the residual is smaller than 

192 backtracking_residual_limit, then further backtracking is not performed. 

193 A value of 100 is suitable for large problems and residual reduction to 

194 smaller values may only slow down computations. backtracking residual 

195 limit only needs to be specified if backtracking_number is greater than 

196 zero. 

197 Default value: None 

198 SolutionPresetSimple: 0.0 

199 SolutionPresetModerate: 0.0 

200 SolutionPresetComplex: 0.002 

201 rclose_option: str, optional 

202 options: {"strict", "l2norm_rclose", "relative_rclose"} 

203 an optional keyword that defines the specific flow residual criterion 

204 used. 

205 strict: an optional keyword that is used to specify that inner rclose 

206 represents a infinity-norm (absolute convergence criteria) and that the 

207 head and flow convergence criteria must be met on the first inner 

208 iteration (this criteria is equivalent to the criteria used by the 

209 MODFLOW-2005 PCG package (Hill, 1990)). 

210 l2norm_rclose: an optionalkeyword that is used to specify that inner 

211 rclose represents a l-2 norm closure criteria instead of a infinity-norm 

212 (absolute convergence criteria). When l2norm_rclose is specified, a 

213 reasonable initial inner rclose value is 0.1 times the number of active 

214 cells when meters and seconds are the defined MODFLOW 6 length and time. 

215 relative_rclose: an optional keyword that is used to specify that 

216 inner_rclose represents a relative L-2 Norm reduction closure criteria 

217 instead of a infinity-Norm (absolute convergence criteria). When 

218 relative_rclose is specified, a reasonable initial inner_rclose value is 

219 1.0 * 10-4 and convergence is achieved for a given inner (linear) 

220 iteration when ∆h ≤ inner_dvclose and the current L-2 Norm is ≤ the 

221 product of the relativ_rclose and the initial L-2 Norm for the current 

222 inner (linear) iteration. If rclose_option is not specified, an absolute 

223 residual (infinity-norm) criterion is used. 

224 Default value: None 

225 SolutionPresetSimple: "strict" 

226 SolutionPresetModerate: "strict" 

227 SolutionPresetComplex: "strict" 

228 relaxation_factor: float, optional 

229 optional real value that defines the relaxation factor used by the 

230 incomplete LU factorization preconditioners (MILU(0) and MILUT). 

231 relaxation_factor is unitless and should be greater than or equal to 0.0 

232 and less than or equal to 1.0. relaxation_factor Iterative Model 

233 Solution 143 values of about 1.0 are commonly used, and experience 

234 suggests that convergence can be optimized in some cases with relax 

235 values of 0.97. A relaxation_factor value of 0.0 will result in either 

236 ILU(0) or ILUT preconditioning (depending on the value specified for 

237 preconditioner_levels and/or preconditioner_drop_tolerance). By default, 

238 relaxation_factor is zero. 

239 Default value: None 

240 SolutionPresetSimple: 0.0 

241 SolutionPresetModerate: 0 

242 SolutionPresetComplex: 0.0 

243 preconditioner_levels: int, optional 

244 optional integer value defining the level of fill for ILU decomposition 

245 used in the ILUT and MILUT preconditioners. Higher levels of fill 

246 provide more robustness but also require more memory. For optimal 

247 performance, it is suggested that a large level of fill be applied (7 or 

248 8) with use of a drop tolerance. Specification of a 

249 preconditioner_levels value greater than zero results in use of the ILUT 

250 preconditioner. By default, preconditioner_levels is zero and the 

251 zero-fill incomplete LU factorization preconditioners (ILU(0) and 

252 MILU(0)) are used. 

253 Default value: None 

254 SolutionPresetSimple: 0 

255 SolutionPresetModerate: 0 

256 SolutionPresetComplex: 5 

257 preconditioner_drop_tolerance: float, optional 

258 optional real value that defines the drop tolerance used to drop 

259 preconditioner terms based on the magnitude of matrix entries in the 

260 ILUT and MILUT preconditioners. A value of 10−4 works well for most 

261 problems. By default, preconditioner_drop_tolerance is zero and the 

262 zero-fill incomplete LU factorization preconditioners (ILU(0) and 

263 MILU(0)) are used. 

264 Default value: None 

265 SolutionPresetSimple: 0 

266 SolutionPresetModerate: 0.0 

267 SolutionPresetComplex: 0.0001 

268 number_orthogonalizations: int, optional 

269 optional integer value defining the interval used to explicitly 

270 recalculate the residual of the flow equation using the solver 

271 coefficient matrix, the latest head estimates, and the right hand side. 

272 For problems that benefit from explicit recalculation of the residual, a 

273 number between 4 and 10 is appropriate. By default, 

274 number_orthogonalizations is zero. 

275 Default value: None 

276 SolutionPresetSimple: 0 

277 SolutionPresetModerate: 0 

278 SolutionPresetComplex: 2 

279 scaling_method: str 

280 options: {None, "diagonal", "l2norm"} 

281 an optional keyword that defines the matrix scaling approach used. By 

282 default, matrix scaling is not applied. 

283 None - no matrix scaling applied. 

284 diagonal - symmetric matrix scaling using the POLCG preconditioner 

285 scaling method in Hill (1992). 

286 l2norm - symmetric matrix scaling using the L2 norm. 

287 Default value: None 

288 reordering_method: str 

289 options: {None, "rcm", "md"} 

290 an optional keyword that defines the matrix reordering approach used. By 

291 default, matrix reordering is not applied. 

292 None - original ordering. 

293 rcm - reverse Cuthill McKee ordering. 

294 md - minimum degree ordering 

295 Default value: None 

296 print_option: str 

297 options: {"none", "summary", "all"} 

298 is a flag that controls printing of convergence information from the 

299 solver. 

300 None - means print nothing. 

301 summary - means print only the total 

302 number of iterations and nonlinear residual reduction summaries. 

303 all - means print linear matrix solver convergence information to the 

304 solution listing file and model specific linear matrix solver 

305 convergence information to each model listing file in addition to 

306 SUMMARY information. 

307 Default value: "summary" 

308 outer_csvfile: str, optional 

309 None if no csv is to be written for the output, str of filename 

310 if csv is to be written. 

311 Default value: None 

312 inner_csvfile: str, optional 

313 None if no csv is to be written for the output, str of filename 

314 if csv is to be written. 

315 Default value: None 

316 no_ptc: str, optional, either None, "all", or "first". 

317 is a flag that is used to disable pseudo-transient continuation (PTC). 

318 Option only applies to steady-state stress periods for models using the 

319 Newton-Raphson formulation. For many problems, PTC can significantly 

320 improve convergence behavior for steady-state simulations, and for this 

321 reason it is active by default. In some cases, however, PTC can worsen 

322 the convergence behavior, especially when the initial conditions are 

323 similar to the solution. When the initial conditions are similar to, or 

324 exactly the same as, the solution and convergence is slow, then this NO 

325 PTC option should be used to deactivate PTC. This NO PTC option should 

326 also be used in order to compare convergence behavior with other MODFLOW 

327 versions, as PTC is only available in MODFLOW 6. 

328 ats_outer_maximum_fraction: float, optional. 

329 real value defining the fraction of the maximum allowable outer iterations 

330 used with the Adaptive Time Step (ATS) capability if it is active. If this 

331 value is set to zero by the user, then this solution will have no effect 

332 on ATS behavior. This value must be greater than or equal to zero and less 

333 than or equal to 0.5 or the program will terminate with an error. If it is 

334 not specified by the user, then it is assigned a default value of one 

335 third. When the number of outer iterations for this solution is less than 

336 the product of this value and the maximum allowable outer iterations, then 

337 ATS will increase the time step length by a factor of DTADJ in the ATS 

338 input file. When the number of outer iterations for this solution is 

339 greater than the maximum allowable outer iterations minus the product of 

340 this value and the maximum allowable outer iterations, then the ATS (if 

341 active) will decrease the time step length by a factor of 1 / DTADJ. 

342 

343 Default value is None. 

344 validate: {True, False} 

345 Flag to indicate whether the package should be validated upon 

346 initialization. This raises a ValidationError if package input is 

347 provided in the wrong manner. Defaults to True. 

348 """ 

349 

350 _pkg_id = "ims" 

351 _keyword_map = {} 

352 

353 _init_schemata = { 

354 "outer_dvclose": [DTypeSchema(np.floating)], 

355 "outer_maximum": [DTypeSchema(np.integer)], 

356 "inner_maximum": [DTypeSchema(np.integer)], 

357 "inner_dvclose": [DTypeSchema(np.floating)], 

358 "inner_rclose": [DTypeSchema(np.floating)], 

359 "linear_acceleration": [OptionSchema(("cg", "bicgstab"))], 

360 "rclose_option": [OptionSchema(("strict", "l2norm_rclose", "relative_rclose"))], 

361 "under_relaxation": [OptionSchema(("simple", "cooley", "dbd"))], 

362 "under_relaxation_theta": [DTypeSchema(np.floating)], 

363 "under_relaxation_kappa": [DTypeSchema(np.floating)], 

364 "under_relaxation_gamma": [DTypeSchema(np.floating)], 

365 "under_relaxation_momentum": [DTypeSchema(np.floating)], 

366 "backtracking_number": [DTypeSchema(np.integer)], 

367 "backtracking_tolerance": [DTypeSchema(np.floating)], 

368 "backtracking_reduction_factor": [DTypeSchema(np.floating)], 

369 "backtracking_residual_limit": [DTypeSchema(np.floating)], 

370 "number_orthogonalizations": [DTypeSchema(np.integer)], 

371 "scaling_method": [OptionSchema(("diagonal", "l2norm"))], 

372 "reordering_method": [OptionSchema(("rcm", "md"))], 

373 "print_option": [OptionSchema(("none", "summary", "all"))], 

374 "no_ptc": [OptionSchema(("first", "all"))], 

375 "ats_outer_maximum_fraction": [ 

376 DTypeSchema(np.floating), 

377 AllValueSchema(">=", 0.0), 

378 AllValueSchema("<=", 0.5), 

379 ], 

380 } 

381 _template = Package._initialize_template(_pkg_id) 

382 

383 @init_log_decorator() 

384 def __init__( 

385 self, 

386 modelnames, 

387 outer_dvclose, 

388 outer_maximum, 

389 inner_maximum, 

390 inner_dvclose, 

391 inner_rclose, 

392 linear_acceleration, 

393 under_relaxation=None, 

394 under_relaxation_theta=None, 

395 under_relaxation_kappa=None, 

396 under_relaxation_gamma=None, 

397 under_relaxation_momentum=None, 

398 backtracking_number=None, 

399 backtracking_tolerance=None, 

400 backtracking_reduction_factor=None, 

401 backtracking_residual_limit=None, 

402 rclose_option=None, 

403 relaxation_factor=None, 

404 preconditioner_levels=None, 

405 preconditioner_drop_tolerance=None, 

406 number_orthogonalizations=None, 

407 scaling_method=None, 

408 reordering_method=None, 

409 print_option="summary", 

410 outer_csvfile=None, 

411 inner_csvfile=None, 

412 no_ptc=None, 

413 ats_outer_maximum_fraction=None, 

414 validate: bool = True, 

415 ): 

416 dict_dataset = { 

417 "outer_dvclose": outer_dvclose, 

418 "outer_maximum": outer_maximum, 

419 "under_relaxation": under_relaxation, 

420 "under_relaxation_theta": under_relaxation_theta, 

421 "under_relaxation_kappa": under_relaxation_kappa, 

422 "under_relaxation_gamma": under_relaxation_gamma, 

423 "under_relaxation_momentum": under_relaxation_momentum, 

424 "backtracking_number": backtracking_number, 

425 "backtracking_tolerance": backtracking_tolerance, 

426 "backtracking_reduction_factor": backtracking_reduction_factor, 

427 "backtracking_residual_limit": backtracking_residual_limit, 

428 "inner_maximum": inner_maximum, 

429 "inner_dvclose": inner_dvclose, 

430 "inner_rclose": inner_rclose, 

431 "rclose_option": rclose_option, 

432 "linear_acceleration": linear_acceleration, 

433 "relaxation_factor": relaxation_factor, 

434 "preconditioner_levels": preconditioner_levels, 

435 "preconditioner_drop_tolerance": preconditioner_drop_tolerance, 

436 "number_orthogonalizations": number_orthogonalizations, 

437 "scaling_method": scaling_method, 

438 "reordering_method": reordering_method, 

439 "print_option": print_option, 

440 "outer_csvfile": outer_csvfile, 

441 "inner_csvfile": inner_csvfile, 

442 "ats_outer_maximum_fraction": ats_outer_maximum_fraction, 

443 "no_ptc": no_ptc, 

444 } 

445 # Make sure the modelnames are set as a variable rather than dimension: 

446 if isinstance(modelnames, xr.DataArray): 

447 dict_dataset["modelnames"] = modelnames 

448 else: 

449 dict_dataset["modelnames"] = ("model", modelnames) 

450 super().__init__(dict_dataset) 

451 self._validate_init_schemata(validate) 

452 

453 def remove_model_from_solution(self, modelname: str) -> None: 

454 models_in_solution = self.get_models_in_solution() 

455 if modelname not in models_in_solution: 

456 raise ValueError( 

457 f"attempted to remove model {modelname} from solution, but it was not found." 

458 ) 

459 filtered_models = [m for m in models_in_solution if m != modelname] 

460 

461 if len(filtered_models) == 0: 

462 self.dataset = self.dataset.drop_vars("modelnames") 

463 else: 

464 self.dataset.update({"modelnames": ("model", filtered_models)}) 

465 

466 def add_model_to_solution(self, modelname: str) -> None: 

467 models_in_solution = self.get_models_in_solution() 

468 if modelname in models_in_solution: 

469 raise ValueError( 

470 f"attempted to add model {modelname} to solution, but it was already in it." 

471 ) 

472 models_in_solution.append(modelname) 

473 self.dataset.update({"modelnames": ("model", models_in_solution)}) 

474 

475 def get_models_in_solution(self) -> list[str]: 

476 models_in_solution = [] 

477 if "modelnames" in self.dataset.keys(): 

478 models_in_solution = list(self.dataset["modelnames"].values) 

479 return models_in_solution 

480 

481 

482def SolutionPresetSimple( 

483 modelnames, 

484 print_option="summary", 

485 outer_csvfile=None, 

486 inner_csvfile=None, 

487 no_ptc=None, 

488): 

489 solution = Solution( 

490 modelnames=modelnames, 

491 print_option=print_option, 

492 outer_csvfile=outer_csvfile, 

493 inner_csvfile=inner_csvfile, 

494 no_ptc=no_ptc, 

495 outer_dvclose=0.001, 

496 outer_maximum=25, 

497 under_relaxation=None, 

498 under_relaxation_theta=0.0, 

499 under_relaxation_kappa=0.0, 

500 under_relaxation_gamma=0.0, 

501 under_relaxation_momentum=0.0, 

502 backtracking_number=0, 

503 backtracking_tolerance=0.0, 

504 backtracking_reduction_factor=0.0, 

505 backtracking_residual_limit=0.0, 

506 inner_maximum=50, 

507 inner_dvclose=0.001, 

508 inner_rclose=0.1, 

509 rclose_option="strict", 

510 linear_acceleration="cg", 

511 relaxation_factor=0.0, 

512 preconditioner_levels=0, 

513 preconditioner_drop_tolerance=0, 

514 number_orthogonalizations=0, 

515 ) 

516 return solution 

517 

518 

519def SolutionPresetModerate( 

520 modelnames, 

521 print_option="summary", 

522 outer_csvfile=None, 

523 inner_csvfile=None, 

524 no_ptc=None, 

525): 

526 solution = Solution( 

527 modelnames=modelnames, 

528 print_option=print_option, 

529 outer_csvfile=outer_csvfile, 

530 inner_csvfile=inner_csvfile, 

531 no_ptc=no_ptc, 

532 outer_dvclose=0.01, 

533 outer_maximum=50, 

534 under_relaxation="dbd", 

535 under_relaxation_theta=0.9, 

536 under_relaxation_kappa=0.0001, 

537 under_relaxation_gamma=0.0, 

538 under_relaxation_momentum=0.0, 

539 backtracking_number=0, 

540 backtracking_tolerance=0.0, 

541 backtracking_reduction_factor=0.0, 

542 backtracking_residual_limit=0.0, 

543 inner_maximum=100, 

544 inner_dvclose=0.01, 

545 inner_rclose=0.1, 

546 rclose_option="strict", 

547 linear_acceleration="bicgstab", 

548 relaxation_factor=0, 

549 preconditioner_levels=0, 

550 preconditioner_drop_tolerance=0.0, 

551 number_orthogonalizations=0, 

552 ) 

553 return solution 

554 

555 

556def SolutionPresetComplex( 

557 modelnames, 

558 print_option="summary", 

559 outer_csvfile=None, 

560 inner_csvfile=None, 

561 no_ptc=None, 

562): 

563 solution = Solution( 

564 modelnames=modelnames, 

565 print_option=print_option, 

566 outer_csvfile=outer_csvfile, 

567 inner_csvfile=inner_csvfile, 

568 no_ptc=no_ptc, 

569 outer_dvclose=0.1, 

570 outer_maximum=100, 

571 under_relaxation="dbd", 

572 under_relaxation_theta=0.8, 

573 under_relaxation_kappa=0.0001, 

574 under_relaxation_gamma=0.0, 

575 under_relaxation_momentum=0.0, 

576 backtracking_number=20, 

577 backtracking_tolerance=1.05, 

578 backtracking_reduction_factor=0.1, 

579 backtracking_residual_limit=0.002, 

580 inner_maximum=500, 

581 inner_dvclose=0.1, 

582 inner_rclose=0.1, 

583 rclose_option="strict", 

584 linear_acceleration="bicgstab", 

585 relaxation_factor=0.0, 

586 preconditioner_levels=5, 

587 preconditioner_drop_tolerance=0.0001, 

588 number_orthogonalizations=2, 

589 ) 

590 return solution