Skip to content

Commit

Permalink
Layer development (#24)
Browse files Browse the repository at this point in the history
* aero rep single particle layer .c and .F90 files

* comments to .F90 code

* adding layers to aero_rep_single_particle_layers.F90

* aero_rep_single_particle_layers.F90 without comments

* fix to indexing

* C preprocessor variables modified

* init aero rep data for layers function

* unique names - need to check if aero_phases is correct

* added LAYER_STATE_ID_ variable

* add and allocate aero_phase array

* creating aero_layer_phase_set array

* ordered layers subroutine

* edits to ordered layers subroutine

* added LAYER_STATE_ID_UNORDERED_ loop to main code

* add second loop with phase names unordered

* add ordered phase function

* aero_phase array constructed

* added layer state id subroutine

* modified ordered functions based on independednt test and edits to notation

* modified functions: removed any variables associated with this

* initialized missing variables and added functions to procedure list

* edited loop to setup aero_phase array to reflect changed made to aero_layer_phase_set

* fixed layer_state_id function and independently tested

* error message to .F90 code, layer and phase tests added to test.F90

* minor .F90 code fixes, tests added and model sucessfully compiled locally!

* some changes to pre-processor definitions

* added variables to aero_rep_data_t

* added sandwich test to check layer and phase ordering

* modified unique_names funtion to reflect layers

* modified unique names function

* fix to unique names function

* .json file and layers test .F90 to repo

* add single particle layered to build and tests

* rough in first test of layer functions

* failed unit testing and json file updates for layers

* passed ordered layer test. reminder - ordered layer function should be modified when initialize function uncommented

* ordered layers test with unit test done

* ordered layer tests with manual input (not from json)

* small change to layer state id test

* attempting to compile initialize function

* trying to resolve errors in initialize function

* fixed string in ordered phase test

* fixing some compiling errors

* fix to initialize

* draft layer data macros

* clean up aero rep layers

* draft unique names function

* add unique names test for layers

* finish cpp macro tests

* modified and in process of testing num_phase_instances function

* trying to fix num_phase_instances test

* passed num_phase_instances test

* resolved matt's comments

* Update src/aero_reps/aero_rep_single_particle_layers.F90

Co-authored-by: Matt Dawson <mattldawson@gmail.com>

* attempting to merge aero rep single particle with layers

* renamed aero_rep_single_particle_layers to aero_rep_single_particle and added layers to tests.  all tests pass except rxns for HL and SIMPOL because they rely on the c functions. next step is to edit c functions

* in the likely event things break

* edited test files to run single particle test with one layer

* aero_rep_single_paricle F90 tests pass, c still fail - bad jacobian element

* modified remaining tests for layers. need to check aero_phase_idx variable

* troubleshooting bad jacobian element error for radius, molecular weight and aero phase mass functions

* printing variables to figure out int_data and float_data stuff

* update to c pre-processor variables LAYER_PHASE_START_ and LAYER_PHASE_END_, corrects output for num_jac_elem c function

* fixed jacobian errors, one layer model working

* testing with 3 layers, still working on c tests

* tests with multiple layers working? seemed too easy so im suspicious

* testing with multiple layers continued

* cleaning up files

* single particle tests still not passing

* radius test passes, need to finish editing other tests

* num conc c test passes, mass and MW failing

* all tests pass for layers

* Update test/unit_aero_rep_data/test_aero_rep_single_particle.F90

Co-authored-by: Jeffrey Curtis <jcurtis2@illinois.edu>

* Update src/aero_reps/aero_rep_single_particle.F90

Co-authored-by: Jeffrey Curtis <jcurtis2@illinois.edu>

* remove print statements

* branch for adding layers to SIMPOL and HL rxns

* fix to print statements and some rxn development

* surface layer boolean array

* make boolean array and tested

* trying to get modal distribution to compile - it wont

* compiles but does not pass tests

* added at surface flag, all tests pass

* coding structure fix

* some comments resolved on PR

* review comments

* PR requested changes

* PR conflicts resolved + new reactions with layers

* Jeff's PR comments

---------

Co-authored-by: Matt Dawson <mattdawson@ucar.edu>
Co-authored-by: Matt Dawson <mattldawson@gmail.com>
Co-authored-by: Jeffrey Curtis <jcurtis2@illinois.edu>
  • Loading branch information
4 people committed Jul 12, 2024
1 parent 978b01a commit b71175d
Show file tree
Hide file tree
Showing 31 changed files with 1,292 additions and 422 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/*.d
**/*.dSym
**/.DS_Store
**/*.pyc
CMakeCache.txt
Expand Down
42 changes: 35 additions & 7 deletions src/aero_rep_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ module camp_aero_rep_data
!! functions of the aerosol representation that cannot be obtained
!! from the camp_camp_state::camp_state_t object. (integer)
integer(kind=i_kind), allocatable, public :: condensed_data_int(:)
!> Array of booleans indicating if phase exists at the surface of a
!! particle. Used in SIMPOL and HL reactions for single particle
!! representation.
logical, allocatable, public :: aero_phase_is_at_surface(:)
!> Number of environment-dependent parameters
!! These are parameters that need updated when environmental conditions
!! change
Expand Down Expand Up @@ -489,26 +493,50 @@ end function get_name

!> Get a set of ids for all instances of a phase in this aerosol
!! representation for use during solving
function phase_ids(this, phase_name)
function phase_ids(this, phase_name, is_at_surface)

!> List of phase ids
integer(kind=i_kind), allocatable :: phase_ids(:)
!> Aerosol representation data
class(aero_rep_data_t), intent(in) :: this
!> Aerosol phase name
character(len=*), intent(in) :: phase_name
!> Indicates if aerosol phase is at the surface of particle
logical, intent(in), optional :: is_at_surface

integer(kind=i_kind) :: num_instances, i_instance, i_phase

num_instances = this%num_phase_instances(phase_name)
allocate(phase_ids(num_instances))
i_instance = 1
do i_phase = 1, size(this%aero_phase)
if (this%aero_phase(i_phase)%val%name().eq.phase_name) then
phase_ids(i_instance) = i_phase
i_instance = i_instance + 1
if (present(is_at_surface)) then
if (is_at_surface) then
i_instance = 1
do i_phase = 1, size(this%aero_phase)
if (this%aero_phase(i_phase)%val%name().eq. phase_name .and. &
this%aero_phase_is_at_surface(i_phase)) then
phase_ids(i_instance) = i_phase
i_instance = i_instance + 1
end if
end do
else
i_instance = 1
do i_phase = 1, size(this%aero_phase)
if (this%aero_phase(i_phase)%val%name().eq. phase_name .and. &
.not. this%aero_phase_is_at_surface(i_phase)) then
phase_ids(i_instance) = i_phase
i_instance = i_instance + 1
end if
end do
end if
end do
else
i_instance = 1
do i_phase = 1, size(this%aero_phase)
if (this%aero_phase(i_phase)%val%name().eq.phase_name) then
phase_ids(i_instance) = i_phase
i_instance = i_instance + 1
end if
end do
end if

end function phase_ids

Expand Down
4 changes: 4 additions & 0 deletions src/aero_reps/aero_rep_modal_binned_mass.F90
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ subroutine initialize(this, aero_phase_set, spec_state_id)

! Allocate space for the aerosol phases and species state ids
allocate(this%aero_phase(num_phase))
allocate(this%aero_phase_is_at_surface(num_phase))
allocate(this%phase_state_id(size(this%aero_phase)))

! Allocate condensed data arrays
Expand Down Expand Up @@ -616,6 +617,9 @@ subroutine initialize(this, aero_phase_set, spec_state_id)

! Add the aerosol phase to the list
this%aero_phase(i_phase) = aero_phase_set(k_phase)

! No species exist at surface
this%aero_phase_is_at_surface(i_phase) = .true.

! Save the starting id for this phase on the state array
this%phase_state_id(i_phase) = curr_spec_state_id
Expand Down
Loading

0 comments on commit b71175d

Please sign in to comment.