430 subroutine initialize(this, var_type, abs_tol, mechanisms, aero_phases, &
431 aero_reps, sub_models, rxn_phase, n_cells)
437 integer(kind=i_kind),
allocatable,
intent(in) :: var_type(:)
441 real(kind=dp),
allocatable,
intent(in) :: abs_tol(:)
443 type(mechanism_data_ptr),
pointer,
intent(in) :: mechanisms(:)
445 type(aero_phase_data_ptr),
pointer,
intent(in) :: aero_phases(:)
447 type(aero_rep_data_ptr),
pointer,
intent(in) :: aero_reps(:)
449 type(sub_model_data_ptr),
pointer,
intent(in) :: sub_models(:)
453 integer(kind=i_kind),
intent(in) :: rxn_phase
455 integer(kind=i_kind),
optional :: n_cells
458 integer(kind=c_int),
pointer :: var_type_c(:)
460 real(kind=c_double),
pointer :: abs_tol_c(:)
462 integer(kind=i_kind) :: i_mech, i_rxn, i_aero_phase, i_aero_rep, &
465 class(rxn_data_t),
pointer :: rxn
467 type(rxn_factory_t) :: rxn_factory
469 type(aero_phase_data_t),
pointer :: aero_phase
471 class(aero_rep_data_t),
pointer :: aero_rep
474 type(aero_rep_factory_t) :: aero_rep_factory
476 class(sub_model_data_t),
pointer :: sub_model
478 type(sub_model_factory_t) :: sub_model_factory
480 integer(kind=c_int),
pointer :: int_param(:)
482 real(kind=c_double),
pointer :: float_param(:)
484 integer(kind=c_int) :: n_rxn
486 integer(kind=c_int) :: n_rxn_int_param
488 integer(kind=c_int) :: n_rxn_float_param
490 integer(kind=c_int) :: n_rxn_env_param
492 integer(kind=c_int) :: n_aero_phase
494 integer(kind=c_int) :: n_aero_phase_int_param
496 integer(kind=c_int) :: n_aero_phase_float_param
498 integer(kind=c_int) :: n_aero_rep
500 integer(kind=c_int) :: n_aero_rep_int_param
502 integer(kind=c_int) :: n_aero_rep_float_param
504 integer(kind=c_int) :: n_aero_rep_env_param
506 integer(kind=c_int) :: n_sub_model
508 integer(kind=c_int) :: n_sub_model_int_param
510 integer(kind=c_int) :: n_sub_model_float_param
512 integer(kind=c_int) :: n_sub_model_env_param
514 integer(kind=c_int) :: l_n_cells
516 if (
present(n_cells))
then
524 call assert_msg(825843466,
size(abs_tol).eq.
size(var_type), &
525 "Mismatched absolute tolerance and variable type arrays: "// &
526 "abs_tol size: "//trim(to_string(
size(abs_tol)))// &
527 "; var_type: "//trim(to_string(
size(var_type))))
530 allocate(var_type_c(
size(var_type)))
531 allocate(abs_tol_c(
size(abs_tol)))
532 var_type_c(:) = int(var_type(:), kind=c_int)
533 abs_tol_c(:) = real(abs_tol(:), kind=c_double)
538 n_rxn_float_param = 0
542 do i_mech=1,
size(mechanisms)
543 do i_rxn=1, mechanisms(i_mech)%val%size()
544 rxn => mechanisms(i_mech)%val%get_rxn(i_rxn)
545 select case (rxn%rxn_phase)
547 if (rxn_phase.eq.aero_rxn) cycle
549 if (rxn_phase.eq.gas_rxn) cycle
551 if (rxn_phase.eq.gas_rxn) cycle
554 n_rxn_int_param = n_rxn_int_param +
size(rxn%condensed_data_int)
555 n_rxn_float_param = n_rxn_float_param +
size(rxn%condensed_data_real)
556 n_rxn_env_param = n_rxn_env_param + rxn%num_env_params
562 n_aero_phase =
size(aero_phases)
563 n_aero_phase_int_param = 0
564 n_aero_phase_float_param = 0
567 do i_aero_phase=1, n_aero_phase
568 aero_phase => aero_phases(i_aero_phase)%val
569 n_aero_phase_int_param = n_aero_phase_int_param + &
570 size(aero_phase%condensed_data_int)
571 n_aero_phase_float_param = n_aero_phase_float_param + &
572 size(aero_phase%condensed_data_real)
577 n_aero_rep =
size(aero_reps)
578 n_aero_rep_int_param = 0
579 n_aero_rep_float_param = 0
580 n_aero_rep_env_param = 0
583 do i_aero_rep=1, n_aero_rep
584 aero_rep => aero_reps(i_aero_rep)%val
585 n_aero_rep_int_param = n_aero_rep_int_param + &
586 size(aero_rep%condensed_data_int)
587 n_aero_rep_float_param = n_aero_rep_float_param + &
588 size(aero_rep%condensed_data_real)
589 n_aero_rep_env_param = n_aero_rep_env_param + &
590 aero_rep%num_env_params
595 n_sub_model =
size(sub_models)
596 n_sub_model_int_param = 0
597 n_sub_model_float_param = 0
598 n_sub_model_env_param = 0
601 do i_sub_model=1, n_sub_model
602 sub_model => sub_models(i_sub_model)%val
603 n_sub_model_int_param = n_sub_model_int_param + &
604 size(sub_model%condensed_data_int)
605 n_sub_model_float_param = n_sub_model_float_param + &
606 size(sub_model%condensed_data_real)
607 n_sub_model_env_param = n_sub_model_env_param + sub_model%num_env_params
613 int(
size(var_type_c), kind=c_int), &
621 n_aero_phase_int_param, &
622 n_aero_phase_float_param, &
624 n_aero_rep_int_param, &
625 n_aero_rep_float_param, &
626 n_aero_rep_env_param, &
628 n_sub_model_int_param, &
629 n_sub_model_float_param, &
630 n_sub_model_env_param &
635 do i_mech=1,
size(mechanisms)
636 do i_rxn=1, mechanisms(i_mech)%val%size()
643 rxn => mechanisms(i_mech)%val%get_rxn(i_rxn)
646 select case (rxn%rxn_phase)
648 if (rxn_phase.eq.aero_rxn) cycle
650 if (rxn_phase.eq.gas_rxn) cycle
652 if (rxn_phase.eq.gas_rxn) cycle
656 allocate(int_param(
size(rxn%condensed_data_int)))
657 allocate(float_param(
size(rxn%condensed_data_real)))
658 int_param(:) = int(rxn%condensed_data_int(:), kind=c_int)
659 float_param(:) = real(rxn%condensed_data_real(:), kind=c_double)
663 int(rxn_factory%get_type(rxn), kind=c_int),&
664 int(
size(int_param), kind=c_int), &
665 int(
size(float_param), kind=c_int), &
666 rxn%num_env_params, &
668 c_loc(float_param), &
673 deallocate(int_param)
674 deallocate(float_param)
681 do i_aero_phase=1,
size(aero_phases)
684 aero_phase => aero_phases(i_aero_phase)%val
687 allocate(int_param(
size(aero_phase%condensed_data_int)))
688 allocate(float_param(
size(aero_phase%condensed_data_real)))
689 int_param(:) = int(aero_phase%condensed_data_int(:), kind=c_int)
690 float_param(:) = real(aero_phase%condensed_data_real(:), kind=c_double)
694 int(
size(int_param), kind=c_int), &
695 int(
size(float_param), kind=c_int), &
697 c_loc(float_param), &
702 deallocate(int_param)
703 deallocate(float_param)
710 do i_aero_rep=1,
size(aero_reps)
713 aero_rep => aero_reps(i_aero_rep)%val
716 allocate(int_param(
size(aero_rep%condensed_data_int)))
717 allocate(float_param(
size(aero_rep%condensed_data_real)))
718 int_param(:) = int(aero_rep%condensed_data_int(:), kind=c_int)
719 float_param(:) = real(aero_rep%condensed_data_real(:), kind=c_double)
723 int(aero_rep_factory%get_type(aero_rep), kind=c_int), &
725 int(
size(int_param), kind=c_int), &
726 int(
size(float_param), kind=c_int), &
727 aero_rep%num_env_params, &
729 c_loc(float_param), &
734 deallocate(int_param)
735 deallocate(float_param)
741 do i_sub_model=1,
size(sub_models)
744 sub_model => sub_models(i_sub_model)%val
747 allocate(int_param(
size(sub_model%condensed_data_int)))
748 allocate(float_param(
size(sub_model%condensed_data_real)))
749 int_param(:) = int(sub_model%condensed_data_int(:), kind=c_int)
750 float_param(:) = real(sub_model%condensed_data_real(:), kind=c_double)
754 int(sub_model_factory%get_type(sub_model), kind=c_int), &
756 int(
size(int_param), kind=c_int), &
757 int(
size(float_param), kind=c_int), &
758 sub_model%num_env_params, &
760 c_loc(float_param), &
765 deallocate(int_param)
766 deallocate(float_param)
775 real(this%rel_tol, kind=c_double), &
776 int(this%max_steps, kind=c_int), &
777 int(this%max_conv_fails, kind=c_int)&
781 this%initialized = .true.
784 deallocate(abs_tol_c)
785 deallocate(var_type_c)
941 type(solver_stats_t),
intent(inout),
target :: solver_stats
945 c_loc( solver_stats%solver_flag ), &
946 c_loc( solver_stats%num_steps ), &
947 c_loc( solver_stats%RHS_evals ), &
948 c_loc( solver_stats%LS_setups ), &
949 c_loc( solver_stats%error_test_fails ), &
950 c_loc( solver_stats%NLS_iters ), &
951 c_loc( solver_stats%NLS_convergence_fails ), &
952 c_loc( solver_stats%DLS_Jac_evals ), &
953 c_loc( solver_stats%DLS_RHS_evals ), &
954 c_loc( solver_stats%last_time_step__s ), &
955 c_loc( solver_stats%next_time_step__s ), &
956 c_loc( solver_stats%Jac_eval_fails ), &
957 c_loc( solver_stats%RHS_evals_total ), &
958 c_loc( solver_stats%Jac_evals_total ), &
959 c_loc( solver_stats%RHS_time__s ), &
960 c_loc( solver_stats%Jac_time__s ), &
961 c_loc( solver_stats%max_loss_precision ) )