-
Notifications
You must be signed in to change notification settings - Fork 0
/
nmgc_main.f90
1908 lines (1639 loc) · 87.5 KB
/
nmgc_main.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!******************************************************************************
! MODULE: nautilus_main
!******************************************************************************
!
! DESCRIPTION:
!> @brief Module that contains all the main routines of nautilus. Usefull to
!! use them in several programs such as nautilus and unitary_tests for instance. \n\n
!!
!
!******************************************************************************
module nautilus_main
use iso_fortran_env
use global_variables
use structure
use input_output
use ode_solver
use dust_temperature_module
implicit none
contains
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!> @author
!> Christophe Cossou
!
!> @date 2014
!
! DESCRIPTION:
!> @brief Routine that contain all initialisation that needs to be done in the code
!! before the integration
!
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subroutine initialisation()
use global_variables
implicit none
! Locals
integer :: i,j ! For loops
real(double_precision), dimension(:), allocatable :: temp_abundances !< Temporary variable to store abundances summed over all 1D points
real(double_precision) :: CHASUM
! Initializing global time
current_time = 0.d0
call read_parameters_in() ! Read simulation parameters. Need to read it before initializing arrays because some of the arrays sizes are carved into it.
call get_grain_radii() ! Read grain radius in cm
call get_YGRAIN() ! initialize character variables YGRAIN and YGRAIN_MINUS
call read_element_in() ! Read list of prime elements, including their atomic mass (in AMU)
call get_array_sizes() ! Get various size needed for allocatable arrays
select case(IS_STRUCTURE_EVOLUTION) ! Initialize structure evolution
case(0)
get_structure_properties => get_structure_properties_fixed
case(1)
call init_structure_evolution()
get_structure_properties => get_structure_properties_table
case default
write(error_unit,*) 'The is_structure_evolution="', IS_STRUCTURE_EVOLUTION,'" cannot be found.'
write(error_unit,*) 'Values possible : 0: no ; 1: yes'
write(error_unit, '(a)') 'Error in structure: subroutine init_structure_evolution'
call exit(9)
end select
! Initialize grain temperature
select case(GRAIN_TEMPERATURE_TYPE)
case('fixed') !Tgrain = initial_Tgrain
get_grain_temperature => get_grain_temperature_fixed
case('fixed_to_dust_size') ! dust temperature read from file for each dust sizes
get_grain_temperature => get_grain_temperature_fixed_to_dust_size
case('table_evolv') ! Tgrain read from a table
get_grain_temperature => get_grain_temperature_table_evolv
case('table_1D') ! Tgrain read from a table
get_grain_temperature => get_grain_temperature_table_1D
case('gas') ! Tgrain = Tgas
get_grain_temperature => get_grain_temperature_gas
case('computed') ! Tgrain computed consistently
get_grain_temperature => get_grain_temperature_computed
case default
write(error_unit,*) 'The GRAIN_TEMPERATURE_TYPE="', GRAIN_TEMPERATURE_TYPE,'" cannot be found.'
write(error_unit,*) 'Values possible : fixed, table_evolv, table_1D, gas, computed'
write(error_unit, '(a)') 'Error in subroutine initialisation.'
call exit(10)
end select
! Init global allocatable arrays. From now on, we can read data files
call initialize_global_arrays()
!0D, 1D_diff, 1D_no_diff
! Initialize structure pointers
select case(STRUCTURE_TYPE)
case('0D') ! No structure at all. Point towards routines that do almost nothing.
get_timestep => get_timestep_0D
structure_diffusion => structure_no_diffusion
case('1D_diff') ! 1D structure with species diffusion
call init_1D_static()
get_timestep => get_timestep_1D_diff
structure_diffusion => structure_diffusion_1D
case('1D_no_diff') ! 1D structure but without species diffusion
call init_1D_static()
get_timestep => get_timestep_0D
structure_diffusion => structure_no_diffusion
case default
write(error_unit,*) 'The STRUCTURE_TYPE="', STRUCTURE_TYPE,'" cannot be found.'
write(error_unit,*) 'Values possible : 0D, 1D_diff, 1D_no_diff'
write(error_unit, '(a)') 'Error in subroutine initialisation.'
call exit(21)
end select
! Read list of species, either for gas or grain reactions
call read_species()
! Read list of reactions for gas and grains
call read_reactions()
! Read branching ratios for the computation of photorates in the case of disks
!if (photo_disk.eq.1) then
! call read_br()
! call read_spec_photo()
! call read_flux_tables()
!else if (photo_disk.eq.0) then
! call read_flux_tables()
!endif
! Overwrite the parameter file to update the syntax, organization and add default values for parameters that did not exist or weren't defined
call write_parameters()
! Set initial abundances. Will define a minimum value for species that are not present in the input file
call read_abundances()
! From the total list of species, determine the exact number of species that are in gas phase, and on the surface of grains.
! This is different from the list in input files were the lists correspond to species NEEDED for reactions in gas phase or on grains.
! Gas species can be needed for surface reactions, and vice versa.
call get_gas_surface_species()
! Initialization of elemental/chemical quantities
call index_datas()
! Calculate the initial abundances for all elements that compose the species
! Here it is assumed that all the cells in 1D have the same elemental abundances
allocate(temp_abundances(nb_species))
temp_abundances(1:nb_species) = sum(abundances(1:nb_species,1:spatial_resolution), dim=2)/float(spatial_resolution)
call get_elemental_abundance(all_abundances=temp_abundances(1:nb_species), el_abundances=INITIAL_ELEMENTAL_ABUNDANCE)
! Store initial elemental abundances
call write_elemental_abundances(filename='elemental_abundances.out', el_abundances=INITIAL_ELEMENTAL_ABUNDANCE)
! Recompute initial_dtg_mass_ratio to remove He
! In the following, initial_dtg_mass_ratio is used as a H/dust mass ratio
do i=1,NB_PRIME_ELEMENTS
if (species_name(PRIME_ELEMENT_IDX(I)).EQ.YHE) then
initial_dtg_mass_ratio = initial_dtg_mass_ratio*(1.d0+4*INITIAL_ELEMENTAL_ABUNDANCE(I))
endif
enddo
! ---NOW COMPUTE THE GRAIN ABUNDANCE---
GTODN = 0.d0
GTODN_FIXED = (4.d0 * PI * GRAIN_DENSITY * grain_radius * grain_radius * grain_radius) / (3.d0*initial_dtg_mass_ratio*AMU)
!if (is_dust_1D.eq.1 .and. nb_grains /=1) then
if ((STRUCTURE_TYPE.eq.'1D_no_diff').and.(nb_grains /=1)) then
GTODN(:) = GTODN_1D_temp(:,1) ! we assign value from space 1 here
do i=1,nb_grains
abundances(INDGRAIN(i),1:spatial_resolution) = 1.0 / GTODN_1D_temp(i,1:spatial_resolution)
abundances(INDGRAIN_MINUS(i),1:spatial_resolution)=0.D0
enddo
!if (is_dust_1D.eq.1 .and. nb_grains ==1) then
elseif ((STRUCTURE_TYPE.eq.'1D_no_diff').and.(nb_grains ==1)) then
do i=1,spatial_resolution
do j=1,nb_grains
abundances(INDGRAIN(j),i)=1/GTODN_1D(j,i)
abundances(INDGRAIN_MINUS(j),i)=0.D0
enddo
enddo
endif
if (STRUCTURE_TYPE.eq.'0D') then
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! added to change the initial way of computing MRN distribution
! sacha Gavino (2024)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if(multi_grain.eq.0) then
GTODN(1)=(4.d0*PI*GRAIN_DENSITY*grain_radii(1)*grain_radii(1)*grain_radii(1))/(3.d0*initial_dtg_mass_ratio*AMU)
abundances(INDGRAIN(i),1:spatial_resolution) = 1.0 / GTODN(i)
elseif(multi_grain.eq.1) then
GTODN(:) = GTODN_0D_temp(:)
do i=1,nb_grains
abundances(INDGRAIN(i),1:spatial_resolution) = 1.0 / GTODN_0D_temp(i)
abundances(INDGRAIN_MINUS(i),1:spatial_resolution)=0.D0
enddo
endif
endif
! else
! if(nb_grains==1) then
! GTODN(1)=(4.d0*PI*GRAIN_DENSITY*grain_radii(1)*grain_radii(1)*grain_radii(1))/(3.d0*initial_dtg_mass_ratio*AMU)
! else
! if(is_dust_MRN == 1) then
! call get_MRN_distribution()
! else
! call get_WD_distribution()
! endif
! endif
! do i=1,nb_grains
! abundances(INDGRAIN(i),1:spatial_resolution) = 1.0 / GTODN(i)
! enddo
!endif !! from the: if (is_dust_1D.eq.1 .and. nb_grains /=1) then
!Compute the initial abundance of electrons
! this is particularly needed for 1D simulations since the subroutine check_conservation is not done in 1D
do j=1,spatial_resolution
CHASUM=0.d0
do I=1,nb_species
if (I.NE.INDEL) CHASUM=CHASUM+SPECIES_CHARGE(I)*abundances(I,j)
enddo
if (CHASUM.LE.0.d0) CHASUM=MINIMUM_INITIAL_ABUNDANCE
abundances(INDEL,j)=CHASUM
enddo
! Set the electron abundance via conservation===========
! And check at the same time that nls_init has the same elemental abundance
! as nls_control
! Make comparison for the sum of abundances for a 0D structure evolving with time. Here the initial abundance of electrons was also computed
if (spatial_resolution.eq.1) then
call check_conservation(abundances(1:nb_species, 1))
! physical structure evolving with time
call get_structure_properties(time=current_time, & ! Inputs
Av=visual_extinction(1), density=H_number_density(1), & ! Outputs
gas_temperature=gas_temperature(1)) ! Outputs
endif
call get_grain_temperature(space=1,time=current_time, gas_temperature=gas_temperature(1), Av=visual_extinction(1), & ! Inputs
grain_temperature=dust_temperature(:,1)) ! Outputs
! We can't add input variables in dlsodes called routines, so we must store the values as global variables
actual_gas_temp = gas_temperature(1)
actual_dust_temp(:) = dust_temperature(:,1)
actual_av = visual_extinction(1)
actual_gas_density = H_number_density(1)
!--------------------------------------------------------------
! below few lines of code scales computed grain temp for different grain radius
! computed grain temperature is only for .1 micron grain so a scaling is done here
if (trim(GRAIN_TEMPERATURE_TYPE)=='computed') then
! write(*,*)grain_radius, actual_dust_temp(1)
write(*,*)
do i=1,nb_grains
actual_dust_temp(i) = actual_dust_temp(i)*(grain_radii(i)/grain_radius)**(-1.d0/6.d0)
! write(*,*)grain_radii(i),actual_dust_temp(i)
enddo
endif
! pause
!--------------------------------------------------------------
! Write species name/index correspondance
call write_species()
! Initialize indices of reactants and products
call set_chemical_reactants()
! Initialize the arrays that list, for each species, the reactions using it as a reactant
!! max_reactions_same_species is set here. nb_reactions_using_species and relevant_reactions array are set here.
call init_relevant_reactions()
! Calculate the optimum number for temporary solving-arrays in ODEPACK, based on the number of non-zeros values in
!! the jacobian
call count_nonzeros()
! Write information about the code at the very end of initialisation
call write_general_infos()
! Do preliminary tests, before starting the integration
! Writing information in 'info.out', appending to the file created by 'write_general_infos'
call preliminary_tests()
if (multi_grain.eq.1) then
WRITE(*,'(a)')'----------------------------------------------------------------------------------------------'
WRITE(*,'(a)')" --- WELCOME TO MULTI-GRAIN MODE --- "
!WRITE(*,'(a)')""
endif
if ((multi_grain.eq.1).and.(structure_type.eq.'0D')) then
WRITE(*,'(a)')'----------------------------------------------------------------------------------------------'
WRITE(*,'(a)')" STRUCTURE: 0D "
WRITE(*,'(a)')" GRAIN MODE: multi-grain "
WRITE(*,'(a)')" GRAIN PARAMETERS: 0D_grain_sizes.in"
WRITE(*,'(a,I3)')" NB OF GRAINS: ", nb_grains
elseif((multi_grain.eq.1).and.(structure_type.eq.'1D_no_diff')) then
WRITE(*,'(a)')'----------------------------------------------------------------------------------------------'
WRITE(*,'(a)')" STRUCTURE: 1D without diffusion "
WRITE(*,'(a)')" GRAIN MODE: multi-grain "
WRITE(*,'(a)')" GRAIN PARAMETERS: 1D_grain_sizes.in"
WRITE(*,'(a,I3)')" NB OF GRAINS: ", nb_grains
elseif((multi_grain.eq.0).and.(structure_type.eq.'0D')) then
WRITE(*,'(a)')'----------------------------------------------------------------------------------------------'
WRITE(*,'(a)')" STRUCTURE: 0D "
WRITE(*,'(a)')" GRAIN MODE: single-grain "
WRITE(*,'(a)')" GRAIN PARAMETERS: parameters.in"
elseif((multi_grain.eq.0).and.(structure_type.eq.'1D_no_diff')) then
WRITE(*,'(a)')'----------------------------------------------------------------------------------------------'
WRITE(*,'(a)')" STRUCTURE: 1D without diffusion "
WRITE(*,'(a)')" GRAIN MODE: single-grain "
WRITE(*,'(a)')" GRAIN PARAMETERS: 1D_static.in"
endif
! WRITE(*,'(a)')""
! WRITE(*,'(a)')'----------------------------------------------------------------------------------------------'
! WRITE(*,'(A)')' STRUCTURE GRAIN MODE GRAIN PARAM GTODN GRAIN_ABUNDANCE'
! do i=1,nb_grains
! write(*,'(I7,10x,4(es12.3,9x))')INDGRAIN(i),grain_radii(i),nb_sites_per_grain(i),GTODN(i),abundances(INDGRAIN(i),1:1)
! enddo
! WRITE(*,'(a)')'----------------------------------------------------------------------------------------------'
if (multi_grain.eq.1) then
WRITE(*,'(a)')'----------------------------------------------------------------------------------------------'
if (structure_type.eq.'1D_no_diff') then
WRITE(*,'(A)')' GRAIN_INDEX GRAIN_RADIUS No_OF_SITES GTODN(0) GRAIN_ABUNDANCE(0)'
elseif (structure_type.eq.'0D') then
WRITE(*,'(A)')' GRAIN_INDEX GRAIN_RADIUS No_OF_SITES GTODN GRAIN_ABUNDANCE'
endif
do i=1,nb_grains
write(*,'(I7,10x,4(es12.3,9x))')INDGRAIN(i),grain_radii(i),nb_sites_per_grain(i),GTODN(i),abundances(INDGRAIN(i),1:1)
enddo
WRITE(*,'(a)')'----------------------------------------------------------------------------------------------'
endif
WRITE(*,'(a)')""
WRITE(*,'(a)')'----> Initialization is done. Integration starts now...'
WRITE(*,'(a)')""
end subroutine initialisation
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!> @author
!> Franck Hersant
!
!> @date 2003
!
! DESCRIPTION:
!> @brief Check if elementary abundances are conserved. If not, display a warning.
!! The option CONSERVATION_TYPE can override abundances and skip the warning display.
!
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subroutine check_conservation(temp_abundances)
use global_variables
implicit none
! Inputs/outputs
real(double_precision), intent(inout), dimension(nb_species) :: temp_abundances !< [in,out] The list of abundances for all species.
!! Can be overwritten if CONSERVATION_TYPE is on, and force conservation.
! Locals
real(double_precision), dimension(NB_PRIME_ELEMENTS) :: elemental_abundance
real(double_precision) :: CHASUM
integer :: i, k
! --- Conserve electrons
CHASUM=0.d0
do I=1,nb_species
if (I.NE.INDEL) CHASUM=CHASUM+SPECIES_CHARGE(I)*temp_abundances(I)
enddo
if (CHASUM.LE.0.d0) CHASUM=MINIMUM_INITIAL_ABUNDANCE
temp_abundances(INDEL)=CHASUM
! --- Conserve other elements if selected
if (CONSERVATION_TYPE.GT.0) then
do K=1,CONSERVATION_TYPE
elemental_abundance(K)=0.d0
enddo
do I=1,nb_species
do K=1,CONSERVATION_TYPE
if (I.NE.PRIME_ELEMENT_IDX(K)) elemental_abundance(K)=elemental_abundance(K)+species_composition(K,I)*temp_abundances(I)
enddo
enddo
do K=1,CONSERVATION_TYPE
temp_abundances(PRIME_ELEMENT_IDX(K))=INITIAL_ELEMENTAL_ABUNDANCE(K)-elemental_abundance(K)
if (temp_abundances(PRIME_ELEMENT_IDX(K)).LE.0.d0) temp_abundances(PRIME_ELEMENT_IDX(K))=MINIMUM_INITIAL_ABUNDANCE
enddo
endif
! Check for conservation
call get_elemental_abundance(all_abundances=temp_abundances, el_abundances=elemental_abundance)
call write_elemental_abundances(filename='elemental_abundances.tmp', el_abundances=elemental_abundance)
! VW fev 2012 add a test for the helium and H2 abundance in the gas phase
! warn for excessive depletion
do k=1,NB_PRIME_ELEMENTS
if (abs(INITIAL_ELEMENTAL_ABUNDANCE(K)-elemental_abundance(K))/INITIAL_ELEMENTAL_ABUNDANCE(K).ge.0.01d0) then
write(Error_unit,*) 'Caution: Element ', trim(species_name(PRIME_ELEMENT_IDX(K))), 'is not conserved'
write(Error_unit,*) 'Relative difference: ', abs(INITIAL_ELEMENTAL_ABUNDANCE(K)-elemental_abundance(K)) / &
INITIAL_ELEMENTAL_ABUNDANCE(K)
endif
if (species_name(PRIME_ELEMENT_IDX(K)).eq.YH) then
if (abs(INITIAL_ELEMENTAL_ABUNDANCE(K)-(temp_abundances(INDH2)*2.D0+temp_abundances(INDH))/ &
INITIAL_ELEMENTAL_ABUNDANCE(K)).ge.0.01d0) then
write(Error_unit,'(a,a,a,es10.2e2,a,a,a,a,a,es10.2e2)') 'H is too depleted on the grains: initial &
& Y(',trim(species_name(K)),') =',INITIAL_ELEMENTAL_ABUNDANCE(K), ' ; Y(',&
& trim(species_name(INDH2)),')*2 + Y(',trim(species_name(INDH)),') =',&
& temp_abundances(INDH2)*2.d0+temp_abundances(INDH)
endif
endif
if (species_name(PRIME_ELEMENT_IDX(K)).eq.YHE) then
if (abs(INITIAL_ELEMENTAL_ABUNDANCE(K)-temp_abundances(INDHE))/INITIAL_ELEMENTAL_ABUNDANCE(K).ge.0.01d0) then
write(Error_unit,'(2(a,a,a,es10.2e2))') 'He is too depleted on the grains: initial Y(',trim(species_name(K)),') =',&
INITIAL_ELEMENTAL_ABUNDANCE(K), ' ; Y(',trim(species_name(INDHE)),')*2 =',temp_abundances(INDHE)
endif
endif
enddo
return
end subroutine check_conservation
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!> @author
!> Christophe Cossou
!
!> @date 2014
!
! DESCRIPTION:
!> @brief Routine that calculate the elemantal abundances from
!! all abundances of all species
!
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subroutine get_elemental_abundance(all_abundances, el_abundances)
implicit none
! Inputs
real(double_precision), intent(in), dimension(nb_species) :: all_abundances !< [in] List of abundances for all existing species
! Outputs
real(double_precision), intent(out), dimension(NB_PRIME_ELEMENTS) :: el_abundances !< [out] list of abundances for all fundamental elements
! Locals
integer :: i,j
el_abundances(1:NB_PRIME_ELEMENTS) = 0.0d0
do i=1,nb_species
do j=1,NB_PRIME_ELEMENTS
el_abundances(j) = el_abundances(j) + species_composition(j,i) * all_abundances(i)
enddo
enddo
end subroutine get_elemental_abundance
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!> @author
!> Franck Hersant
!
!> @date 2003
!
! DESCRIPTION:
!> @brief Read and retrieve information for species.
!! Save index for prime elements in the full species array
!!
!! Save other interesting index for special species
!
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subroutine index_datas()
use global_variables
implicit none
! Locals
real(double_precision) :: MSUM
integer :: ILAB, j, k, i, isptemp
integer :: KSUM ! sum of number of primary element composing the species. If equal to 1, the current species is elemental
real(double_precision) :: mass_tmp !< temporary value to exchange two index in the mass array
character(len=11) :: name_tmp !< temporary value to exchange two index in the name array
! Set elements' characteristics=========================================
! --- Find the atomic species associated with a given element
ILAB=1
do J=1,nb_species
KSUM=0
! ------ Calculate species' elemental_mass
do K=1,NB_PRIME_ELEMENTS
KSUM=KSUM+species_composition(K,J)
enddo
! ------ Check for atomic species
if ((KSUM.EQ.1).AND.(SPECIES_CHARGE(J).EQ.0).AND.&
(species_name(J)(:1).NE.'J').AND.(species_name(J)(:1).NE.'K').AND.(species_name(J)(:1).NE.'X')) then
if (ILAB.GT.NB_PRIME_ELEMENTS) then
write(Error_unit, *) '***More fundamental elements than NB_PRIME_ELEMENTS***'
call exit(3)
endif
! --------- Save species number
PRIME_ELEMENT_IDX(ILAB)=J
ILAB=ILAB+1
endif
! ------ Check for electron species number
IF (species_name(J).EQ.YE) then
INDEL=J
endif
enddo
! --- Re-arrange order of elements to match species_composition columns (reactions file)
do J=1,NB_PRIME_ELEMENTS-1
if (species_composition(J,PRIME_ELEMENT_IDX(J)).NE.1) then
do K=J+1,NB_PRIME_ELEMENTS
if (species_composition(J,PRIME_ELEMENT_IDX(K)).EQ.1) then
ISPTEMP=PRIME_ELEMENT_IDX(K)
! mass_tmp = elemental_mass(k)
! name_tmp = element_name(k)
! elemental_mass(k) = elemental_mass(j)
! element_name(k) = element_name(j)
PRIME_ELEMENT_IDX(K)=PRIME_ELEMENT_IDX(J)
! elemental_mass(k) = mass_tmp
! element_name(k) = name_tmp
PRIME_ELEMENT_IDX(J)=ISPTEMP
endif
enddo
endif
enddo
! Set species' characteristics==========================================
! --- Set reference species
do I=1,nb_species
! ------ Calculate elemental_masses
MSUM=0.d0
do K=1,NB_PRIME_ELEMENTS
MSUM=MSUM+elemental_mass(K)*species_composition(K,I)
enddo
SPECIES_MASS(I)=MSUM
if (species_name(I).EQ.YE) SPECIES_MASS(I) = ELECTRON_MASS ! electron mass in amu
! if (species_name(I).EQ.YGRAIN(1) .OR. species_name(I).EQ.'GRAIN01- ') then
! if (nb_grains ==1 ) &
! SPECIES_MASS(I)=4.0*PI*grain_radii(1)*grain_radii(1)*grain_radii(1)*GRAIN_DENSITY/3.0/AMU
! if (nb_grains /= 1) then grain mass is calculated by subroutine get_grain_mass
! endif
enddo
call get_grain_mass()
! Initialize the Av/NH ratio
! Can be scaled for different dust/gas ratios
! Here initial_dtg_elemental_mass_ratio is the original dust/gas elemental_mass ratio (from nls_control.d)
! initial_dtg_elemental_mass_ratio is changed later into the dust/hydrogen elemental_mass ratio
AV_NH_ratio = 5.34d-22 * (initial_dtg_mass_ratio / 1.d-2)
! Find ITYPE first and last reactions===================================
do I=0,MAX_NUMBER_REACTION_TYPE-1
type_id_start(I)=0
type_id_stop(I)=0
do J=1,nb_reactions
if ((REACTION_TYPE(J).EQ.I).AND.(type_id_start(I).EQ.0)) type_id_start(I)=J
if (REACTION_TYPE(J).EQ.I) type_id_stop(I)=J
enddo
enddo
! Find the index of CO, H2, H, He and grain0 PLUS H2O and a few other contained in folder cross-sections.
do i=1,nb_species
if (species_name(i).eq.YH2) INDH2=i
if (species_name(i).eq.YH) INDH=i
if (species_name(i).eq.YCO) INDCO=i
if (species_name(i).eq.YKCO) INDKCO=i
if (species_name(i).eq.YJCO) INDJCO=i
if (species_name(i).eq.YH2O) INDH2O=i
if (species_name(i).eq.YKH2O) INDKH2O=i
if (species_name(i).eq.YJH2O) INDJH2O=i
if (species_name(i).eq.YHE) INDHE=i
if (species_name(i).eq.YN2) INDN2=i
if (species_name(i).eq.YCH) INDCH=i
if (species_name(i).eq.YCH3) INDCH3=i
if (species_name(i).eq.YH2CO) INDH2CO=i
do j=1,nb_grains
if (species_name(i).eq.YGRAIN(j)) INDGRAIN(j)=i
if (species_name(i).eq.YGRAIN_MINUS(j)) INDGRAIN_MINUS(j)=i
enddo
enddo
! Compute nb_sites_per_grain = number of sites per grain
do j=1,nb_grains
nb_sites_per_grain(j) = 4.d0*PI*SURFACE_SITE_DENSITY*grain_radii(j)*grain_radii(j)
! write(*,*)j,grain_radii(j),nb_sites_per_grain(j)
enddo
! Initialise reaction rates=============================================
call init_reaction_rates()
return
end subroutine index_datas
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!> @author
!> Franck Hersant
!
!> @date 2000
!
! DESCRIPTION:
!> @brief compute surface info (thermodynamic, quantum and kinetic data)
!! from datafiles
!
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subroutine init_reaction_rates()
use global_variables
implicit none
! Locals
real(double_precision), dimension(nb_species) :: REA1,REA2,REA3,REA4
real(double_precision), dimension(nb_reactions) :: REA5
real(double_precision), dimension(nb_species) :: SMASS
real(double_precision) :: SMA,REDMAS,STICK,EVFRAC,DHFSUM,SUM1,SUM2
integer, dimension(nb_reactions) :: INT1
integer :: NGS,NEA,NPATH,NEVAP,BADFLAG,ATOMS
character(len=11), dimension(MAX_COMPOUNDS,nb_reactions) :: GSREAD
character(len=11), dimension(nb_species) :: GSPEC
real(double_precision),allocatable, dimension(:) :: COND
integer :: i, j,k,l,n4, n5, n6
character(len=80) :: filename !< name of the file to be read
character(len=80) :: line_format
character(len=200) :: line
character(len=1), parameter :: comment_character = '!' !< character that will indicate that the rest of the line is a comment
integer :: comment_position !< the index of the comment character on the line. if zero, there is none on the current string
integer :: error !< to store the state of a read instruction
logical :: isDefined
character(2) :: i_c !character variable to convert integer value of j to character j
allocate(COND(nb_grains))
COND(1:nb_grains) = 0.d0
! Set accretion rate====================================================
! COND is used to calculate R_acc = (sigma_d) * <v_i> * n_i * n_d
! Uses 'Mean' Maxwellian speed, rather than RMS (is this justifiable?)
! COND=PI*grain_radius*grain_radius*SQRT(8.0d0*K_B/PI/AMU)
do i=1,nb_grains
COND(i)=PI*grain_radii(i)*grain_radii(i)*SQRT(8.0d0*K_B/PI/AMU)
! write(*,*)cond(i),grain_radii(i)
enddo
! pause
! --- Evaluate sticking coeff and accretion rate factor for each species
STICK=0.d0
do I=1,nb_species
if (SPECIES_CHARGE(I).EQ.0) then
STICK = sticking_coeff_neutral
else if (SPECIES_CHARGE(I).GT.0) then
STICK = sticking_coeff_positive
else ! (SPECIES_CHARGE(I).LT.0)
STICK = sticking_coeff_negative
endif
! if (species_name(I).EQ.YH2) STICK=0.d0
! if (species_name(I).EQ.YHE) STICK=0.d0
! if (species_name(I).EQ.YH) STICK=0.d0
if (species_name(I).EQ.YHEP) STICK=0.d0
if (species_name(I).EQ.'e- ') STICK=0.d0
if (species_name(I).EQ.'H+ ') STICK=0.d0
do j=1,nb_grains
if (species_name(I).EQ.YGRAIN(j)) STICK=0.d0
if (species_name(I).EQ.YGRAIN_MINUS(j)) STICK=0.d0
enddo
! if (species_name(I).EQ.'H-') STICK=0.d0
! if (species_name(I).EQ.'H2+') STICK=0.d0
if (I.GT.nb_gaseous_species) STICK=0.d0
STICK_SPEC(i)=STICK
! ACC_RATES_PREFACTOR(I)=COND*STICK/SQRT(SPECIES_MASS(I))
! write(223,*)i,STICK_SPEC(i) ,species_name(I)
enddo
! Read in molecular information for surface rates=======================
! Reading list of species for gas phase
filename = 'surface_parameters.in'
inquire(file=filename, exist=isDefined)
if (isDefined) then
call get_linenumber(filename=filename, nb_lines=NGS)
open(10, file=filename, status='old')
i = 0
do
read(10, '(a)', iostat=error) line
if (error /= 0) exit
! We get only what is on the left of an eventual comment parameter
comment_position = index(line, comment_character)
! if there are comments on the current line, we get rid of them
if (comment_position.ne.0) then
line = line(1:comment_position - 1)
end if
if (line.ne.'') then
i = i + 1
read(line, '(A11,I4,F7.0,F6.0,D8.1,27X,F8.2)') GSPEC(I),INT1(I),REA1(I),REA2(I),REA3(I),REA4(I)
write(i_c,'(I2.2)')1
GSPEC(i) = GSPEC(i)(:1)//trim(i_c)//GSPEC(i)(2:)
do j=1,nb_grains-1
i = i + 1
write(i_c,'(I2.2)')j+1
GSPEC(I)= GSPEC(I-j)(:1)//trim(i_c)//GSPEC(I-j)(4:)
INT1(I) = INT1(I-j)
REA1(I) = REA1(I-j)
REA2(I) = REA2(I-j)
REA3(I) = REA3(I-j)
REA4(I) = REA4(I-j)
enddo
end if
end do
NGS = i
close(10)
! do i=1,NGS
! write(*, '(A11,I4,F7.0,F6.0,D8.1,27X,F8.2)') GSPEC(I),INT1(I),REA1(I),REA2(I),REA3(I),REA4(I)
! enddo
! pause
else
write(Error_unit,*) 'Error: The file ', trim(filename),' does not exist.'
call exit(1)
end if
filename = 'activation_energies.in'
inquire(file=filename, exist=isDefined)
if (isDefined) then
call get_linenumber(filename=filename, nb_lines=NEA)
! Definition of the line format, common to gas_reaction.in and grain_reaction.in
write(line_format, '(a,i0,a,i0,a)') '(', MAX_REACTANTS, 'A11,4x,', MAX_PRODUCTS, 'A11,D9.2)'
open(10, file=filename, status='old')
i = 0
do
read(10, '(a)', iostat=error) line
if (error /= 0) exit
! We get only what is on the left of an eventual comment parameter
comment_position = index(line, comment_character)
! if there are comments on the current line, we get rid of them
if (comment_position.ne.0) then
line = line(1:comment_position - 1)
end if
if (line.ne.'') then
i = i + 1
read(line, line_format) (GSread(L,i),L=1,MAX_COMPOUNDS),REA5(i)
if((GSread(1,i)(1:1).eq.'J').or.(GSread(1,i)(1:1).eq.'K') .or. &
(GSread(2,i)(1:1).eq.'J').or.(GSread(2,i)(1:1).eq.'K') .or. &
(GSread(3,i)(1:1).eq.'J').or.(GSread(3,i)(1:1).eq.'K') .or. &
(GSread(4,i)(1:1).eq.'J').or.(GSread(4,i)(1:1).eq.'K') .or. &
(GSread(5,i)(1:1).eq.'J').or.(GSread(5,i)(1:1).eq.'K') .or. &
(GSread(6,i)(1:1).eq.'J').or.(GSread(6,i)(1:1).eq.'K') .or. &
(GSread(7,i)(1:1).eq.'J').or.(GSread(7,i)(1:1).eq.'K') .or. &
(GSread(8,i)(1:1).eq.'J').or.(GSread(8,i)(1:1).eq.'K') ) then
write(i_c,'(I2.2)')1
do j=1,8
if(GSread(j,i)(:1)=='J' .or. GSread(j,i)(:1)=='K') then
GSread(j,i)=GSread(j,i)(:1)//trim(i_c)//GSread(j,i)(2:)
endif
enddo
do j=1,nb_grains-1
i=i+1
write(i_c,'(I2.2)')j+1
do k=1,8
if(GSread(k,i-j)(:1)=='J' .or. GSread(k,i-j)(:1)=='K') then
GSread(k,i)=GSread(k,i-j)(:1)//trim(i_c)//GSread(k,i-j)(4:)
else
GSread(k,i) = GSread(k,i-j)
endif
REA5(i) = REA5(i-j)
enddo
enddo
endif
endif
enddo
! do j=1,i
! write(*,line_format)(GSread(L,j),L=1,MAX_COMPOUNDS),REA5(j)
! enddo
! pause
NEA = i
close(10)
else
write(Error_unit,*) 'Error: The file ', trim(filename),' does not exist.'
call exit(1)
end if
! --- Transfer from dummies to arrays with correct species numbers
do I=1,nb_species
SMASS(I)=0.d0
BINDING_ENERGY(I)=0.d0
DIFFUSION_BARRIER(I)=0.d0
GAP_ENERGY_BANDS(I)=0.d0
FORMATION_ENTHALPY(I)=0.d0
do J=1,NGS
if (species_name(I).EQ.GSPEC(J)) then
SMASS(I)=dble(INT1(J))
BINDING_ENERGY(I)=REA1(J)
DIFFUSION_BARRIER(I)=REA2(J)
GAP_ENERGY_BANDS(I)=REA3(J)
FORMATION_ENTHALPY(I)=REA4(J)
! VW April 2016 Changing this in order to compute the H2 diffusion barrier the same way as for the other
! species since we do not have any idea of its real value contrary to H.
! if ((species_name(I).NE.YJH).AND.(species_name(I).NE.YJH2).AND.&
! if ((species_name(I).NE.YJH).AND.&
!due to multi grain system it is not possible to check with only YJH as we need to do same for J02H, J03H and so on
!so, explicitely comparing with 'H '
if ((species_name(I)(4:11).NE.'H ').AND.&
(DIFF_BINDING_RATIO_SURF.GE.0.d0).AND.(species_name(i)(1:1).eq."J")) then
DIFFUSION_BARRIER(I)=DIFF_BINDING_RATIO_SURF*BINDING_ENERGY(I)
! elseif ((species_name(I).NE.YKH).AND.(species_name(I).NE.YKH2).AND.&
! elseif ((species_name(I).NE.YKH).AND.&
elseif ((species_name(I)(4:11).NE.'H ').AND.&
(DIFF_BINDING_RATIO_MANT.GE.0.d0).AND.(species_name(i)(1:1).eq."K")) then
DIFFUSION_BARRIER(I)=DIFF_BINDING_RATIO_MANT*BINDING_ENERGY(I)
endif
endif
enddo
enddo
! For each reaction, we search if there is an activation energy defined for it.
! the "all()" function can compare array element by element to ensure that everything is equal one by one. usefull to find
! if we have the good reaction
do I=1,nb_reactions
ACTIVATION_ENERGY(I)=0.d0
do J=1,NEA
if ((REACTION_COMPOUNDS_NAMES(MAX_REACTANTS+1,I)(:1).EQ.'J').OR.&
(REACTION_COMPOUNDS_NAMES(MAX_REACTANTS+1,I)(:1).EQ.'K')) then
if (all(REACTION_COMPOUNDS_NAMES(1:MAX_COMPOUNDS,I).EQ.GSread(1:MAX_COMPOUNDS,J))) then
ACTIVATION_ENERGY(I) = REA5(J)
endif
else
if (all((REACTION_COMPOUNDS_NAMES(1:MAX_REACTANTS,I).EQ.GSread(1:MAX_REACTANTS,J))).AND.&
(all(REACTION_COMPOUNDS_NAMES(MAX_REACTANTS+1:MAX_COMPOUNDS,I).EQ.GSread(MAX_REACTANTS+1:MAX_COMPOUNDS,J)(4:)))) then
ACTIVATION_ENERGY(I) = REA5(J)
endif
endif
enddo
enddo
! Set up constants, quantum rate info===================================
do I=1,nb_species
VIBRATION_FREQUENCY(I)=0.d0
TUNNELING_RATE_TYPE_1(I)=0.d0
TUNNELING_RATE_TYPE_2(I)=0.d0
! ------ For species which have been assigned surface info, SMASS=/=0
if (SMASS(I).NE.0) then
SMA=dble(SMASS(I))
! --------- Set characteristic frequency
VIBRATION_FREQUENCY(I)=SQRT(2.0d0*K_B/PI/PI/AMU * SURFACE_SITE_DENSITY*BINDING_ENERGY(I)/SMA)
! --------- Set quantum rates
if (GAP_ENERGY_BANDS(I).GE.1.0D-38) then
! TUNNELING_RATE_TYPE_1(I)=GAP_ENERGY_BANDS(I)*K_B/4.0d0/H_BARRE/nb_sites_per_grain
TUNNELING_RATE_TYPE_1(I)=GAP_ENERGY_BANDS(I)*K_B/4.0d0/H_BARRE
else
TUNNELING_RATE_TYPE_1(I)=0.d0
endif
! TUNNELING_RATE_TYPE_2(I) = VIBRATION_FREQUENCY(I) / nb_sites_per_grain * &
! EXP(-2.0d0*DIFFUSION_BARRIER_THICKNESS/H_BARRE*SQRT(2.0d0*AMU*SMA*K_B*DIFFUSION_BARRIER(I)))
TUNNELING_RATE_TYPE_2(I) = VIBRATION_FREQUENCY(I) * &
EXP(-2.0d0*DIFFUSION_BARRIER_THICKNESS/H_BARRE*SQRT(2.0d0*AMU*SMA*K_B*DIFFUSION_BARRIER(I)))
endif
! write(99,'(a,es12.3,F12.3)')species_name(i), VIBRATION_FREQUENCY(I),sma
enddo
! pause
! === Cycle all reactions
do J=1,nb_reactions
! ------ Initialise all branching_ratio rate factors, and get species 1 & 2
branching_ratio(J)=1.0d0
reactant_1_idx(J)=0
reactant_2_idx(J)=0
do I=1,nb_species
if (REACTION_COMPOUNDS_NAMES(1,J).EQ.species_name(I)) reactant_1_idx(J)=I
if (REACTION_COMPOUNDS_NAMES(2,J).EQ.species_name(I)) reactant_2_idx(J)=I
enddo
! === ITYPE 14 AND 21 - SURFACE REACTIONS
if (REACTION_TYPE(J).EQ.14 .OR. REACTION_TYPE(J).EQ.21 .OR. REACTION_TYPE(J).EQ.30) then
NPATH=0
! ------ Check for branching
do K=1,nb_reactions
if(REACTION_TYPE(K).EQ.REACTION_TYPE(J)) then
if (((REACTION_COMPOUNDS_NAMES(1,J).EQ.REACTION_COMPOUNDS_NAMES(1,K)).AND.&
(REACTION_COMPOUNDS_NAMES(2,J).EQ.REACTION_COMPOUNDS_NAMES(2,K))).OR.&
((REACTION_COMPOUNDS_NAMES(2,J).EQ.REACTION_COMPOUNDS_NAMES(1,K)).AND.&
(REACTION_COMPOUNDS_NAMES(1,J).EQ.REACTION_COMPOUNDS_NAMES(2,K)))) then
if (REACTION_COMPOUNDS_NAMES(4,K)(:1).EQ.'J'.OR.&
REACTION_COMPOUNDS_NAMES(4,K)(:1).EQ.'K') NPATH=NPATH+1
endif
endif
enddo
! ------ Branching ratio
if (NPATH.EQ.0) then
branching_ratio(J)=0.d0
else
IF(REACTION_COMPOUNDS_NAMES(1,J)(4:11) == "C-H2O " .AND. REACTION_COMPOUNDS_NAMES(2,J)(4:11) == "H ") THEN
IF(REACTION_COMPOUNDS_NAMES(1,J)(1:1) == "J" .AND. REACTION_COMPOUNDS_NAMES(2,J)(1:1) == "J") THEN
IF(is_er_cir==1) THEN
IF(REACTION_COMPOUNDS_NAMES(4,J)(4:11) == "CH2OH " .AND. REACTION_COMPOUNDS_NAMES(4,J)(1:1) =="J") &
branching_ratio(J)=branching_ratio(J)*0.490d+00
IF(REACTION_COMPOUNDS_NAMES(4,J) == "CH2OH ") &
branching_ratio(J)=branching_ratio(J)*0.490d+00
IF(REACTION_COMPOUNDS_NAMES(4,J)(4:11) == "CH3O " .AND. REACTION_COMPOUNDS_NAMES(4,J)(1:1) =="J") &
branching_ratio(J)=branching_ratio(J)*0.490d+00
IF(REACTION_COMPOUNDS_NAMES(4,J) == "CH3O ") &
branching_ratio(J)=branching_ratio(J)*0.490d+00
IF(REACTION_COMPOUNDS_NAMES(4,J)(4:11) == "CH-H2O " .AND. REACTION_COMPOUNDS_NAMES(4,J)(1:1) =="J") &
branching_ratio(J)=branching_ratio(J)*0.01d+00
IF(REACTION_COMPOUNDS_NAMES(4,J)(4:11) == "H2O " .AND. REACTION_COMPOUNDS_NAMES(4,J)(1:1) =="J" &
.AND. REACTION_COMPOUNDS_NAMES(5,J) == "CH ") &
branching_ratio(J)=branching_ratio(J)*0.01d+00
!WRITE(*,"(8(a11),f8.3,a)") REACTION_COMPOUNDS_NAMES(:,J), branching_ratio(J)*100, "%"
ENDIF
ENDIF
ELSEIF (REACTION_COMPOUNDS_NAMES(1,J)(4:11) == "C-CH3OH " .AND. REACTION_COMPOUNDS_NAMES(2,J)(4:11) == "H ") THEN
IF(REACTION_COMPOUNDS_NAMES(1,J)(1:1) == "J" .AND. REACTION_COMPOUNDS_NAMES(2,J)(1:1) == "J") THEN
IF(is_er_cir==1) THEN
IF(REACTION_COMPOUNDS_NAMES(4,J)(4:11) == "CH3OCH2 " .AND. REACTION_COMPOUNDS_NAMES(4,J)(1:1) =="J") &
branching_ratio(J)=branching_ratio(J)*0.98d+00
IF( REACTION_COMPOUNDS_NAMES(4,J) == "CH3OCH2 ") &
branching_ratio(J)=branching_ratio(J)*0.98d+00
IF(REACTION_COMPOUNDS_NAMES(4,J)(4:11) == "CH-CH3OH" .AND. REACTION_COMPOUNDS_NAMES(4,J)(1:1) =="J") &
branching_ratio(J)=branching_ratio(J)*0.01d+00
IF(REACTION_COMPOUNDS_NAMES(4,J)(4:11) == "CH3OH " .AND. REACTION_COMPOUNDS_NAMES(4,J)(1:1) =="J" &
.AND. REACTION_COMPOUNDS_NAMES(5,J) == "CH ") &
branching_ratio(J)=branching_ratio(J)*0.01d+00
!WRITE(*,"(8(a11),f8.3,a)") REACTION_COMPOUNDS_NAMES(:,J), branching_ratio(J)*100, "%"
ENDIF
ENDIF
ELSEIF (REACTION_COMPOUNDS_NAMES(1,J)(4:11) == "C-CO2 " .AND. REACTION_COMPOUNDS_NAMES(2,J)(4:11) == "H ") THEN
IF(REACTION_COMPOUNDS_NAMES(1,J)(1:1) == "J" .AND. REACTION_COMPOUNDS_NAMES(2,J)(1:1) == "J") THEN
IF(is_er_cir==1) THEN
IF(REACTION_COMPOUNDS_NAMES(4,J)(4:11) == "HCOCO " .AND. REACTION_COMPOUNDS_NAMES(4,J)(1:1) =="J") &
branching_ratio(J)=branching_ratio(J)*0.00d+00
IF( REACTION_COMPOUNDS_NAMES(4,J) == "HCOCO ") &
branching_ratio(J)=branching_ratio(J)*0.00d+00
IF(REACTION_COMPOUNDS_NAMES(4,J)(4:11) == "HCO " .AND. REACTION_COMPOUNDS_NAMES(4,J)(1:1) =="J") &
branching_ratio(J)=branching_ratio(J)*0.98d+00