CAMP 1.0.0
Chemistry Across Multiple Phases
part_1_code/box_model.F90
Go to the documentation of this file.
1!! [Modules to use]
2program box_model
3
7 !! [Modules to use]
8
9 !! [Chem-spec data module]
11
12 !! [Chem-spec data module]
13
14 !! [Core and state]
15 type(camp_core_t), pointer :: camp_core
16 type(camp_state_t), pointer :: camp_state
17
18 !! [Core and state]
19
20 !! [Species ids]
21 integer(kind=i_kind) :: idx_o3, idx_no, idx_no2, idx_o2
22 type(chem_spec_data_t), pointer :: chem_spec_data
23
24 !! [Species ids]
25
26 !! [Output variables]
27 character(len=*), parameter :: fmt_hdr = "(A10,',',A10,',',A10,',',A10,',',A10)"
28 character(len=*), parameter :: fmt_dat = "(ES10.4,',',ES10.4,',',ES10.4,',',ES10.4,',',ES10.4)"
29
30 !! [Output variables]
31
32 !! [Time id]
33 integer(kind=i_kind) :: i_time
34
35 !! [Time id]
36
37 !! [Initialize core]
38 camp_core => camp_core_t( "my_config_file.json" )
39 call camp_core%initialize( )
40 !! [Initialize core]
41
42 !! [Get species ids]
43 if( .not.camp_core%get_chem_spec_data( chem_spec_data ) ) then
44 write(*,*) "Something's gone wrong!"
45 stop 3
46 end if
47
48 idx_o3 = chem_spec_data%gas_state_id( "O3" )
49 idx_no = chem_spec_data%gas_state_id( "NO" )
50 idx_no2 = chem_spec_data%gas_state_id( "NO2" )
51 idx_o2 = chem_spec_data%gas_state_id( "O2" )
52 if( idx_o3.eq.0 .or. idx_no2.eq.0 .or.idx_o2.eq.0 ) then
53 write(*,*) "Missing species!"
54 stop 3
55 end if
56 !! [Get species ids]
57
58 !! [Set initial conditions]
59 call camp_core%solver_initialize( )
60 camp_state => camp_core%new_state( )
61
62 call camp_state%env_states(1)%set_temperature_K( 275.4_dp )
63 call camp_state%env_states(1)%set_pressure_Pa( 101532.2_dp )
64
65 camp_state%state_var( idx_o3 ) = 0.13 ! [O3] in ppm
66 camp_state%state_var( idx_no ) = 0.02 ! [NO] in ppm
67 camp_state%state_var( idx_no2 ) = 0.053 ! [NO2] in ppm
68 camp_state%state_var( idx_o2 ) = 2.1e5 ! [O2] in ppm
69 !! [Set initial conditions]
70
71 !! [Solve and output]
72 write(*,fmt_hdr) "time", "O3", "NO", "NO2", "O2"
73 do i_time = 1, 100
74 call camp_core%solve( camp_state, 1.0d-15 ) ! time step in s
75 write(*,fmt_dat) i_time*1.0e-15, &
76 camp_state%state_var( idx_o3 ), &
77 camp_state%state_var( idx_no ), &
78 camp_state%state_var( idx_no2 ), &
79 camp_state%state_var( idx_o2 )
80 end do
81
82 deallocate( camp_core )
83 deallocate( camp_state )
84
85end program box_model
86!! [Solve and output]
The camp_core_t structure and associated subroutines.
Definition camp_core.F90:87
The camp_state_t structure and associated subroutines.
Definition camp_state.F90:9
The chem_spec_data_t structure and associated subroutines.
Physical constants.
Definition constants.F90:9
program box_model
Part-MC model data.