Skip to content

Add script to compute vertical coordinate for initial condition#495

Merged
mark-petersen merged 9 commits intoMPAS-Dev:ocean/developfrom
mark-petersen:ocean/vertical_coordinate_script
Apr 2, 2020
Merged

Add script to compute vertical coordinate for initial condition#495
mark-petersen merged 9 commits intoMPAS-Dev:ocean/developfrom
mark-petersen:ocean/vertical_coordinate_script

Conversation

@mark-petersen
Copy link
Contributor

Previously, the vertical coordinate (layer depths) was read from a file when generating initial conditions in COMPASS. This adds a script with input parameters and adds it to the COMPASS init sequence. This will be used to create a 64-layer domain for the EC60to30 and others right now.

@mark-petersen
Copy link
Contributor Author

@vanroekel thanks for providing the script. I only altered formatting, but not content.

@mark-petersen
Copy link
Contributor Author

I added a little plotting routine to the script. Parameters are in bottom right.
vertical_grid
I just made a guess at 10m and 125m for layer min and max. @vanroekel and @maltrud do you have a recommendation for the new 64-layer grid?

@mark-petersen mark-petersen force-pushed the ocean/vertical_coordinate_script branch 2 times, most recently from 593322b to 36deeba Compare March 30, 2020 20:16
@mark-petersen
Copy link
Contributor Author

Here are the current settings for the 64-layer grid:

number layers: 64
bottom depth requested:   5500.00
bottom depth actual:      5647.01
min thickness reqeusted:     2.00
min thickness actual:        1.98
max thickness reqeusted:   200.00
max thickness actual:      194.39

vertical_grid

@maltrud
Copy link
Contributor

maltrud commented Mar 30, 2020

@mark-petersen: Andrew Roberts (@proteanplanet) has generated a 64 level profile. maybe using the same code, but you should make sure you guys are on the same page.

@mark-petersen
Copy link
Contributor Author

@proteanplanet, please check the layer distribution above. Can you check against or post your 64-layer grid? Did you use the script from @vanroekel or something else?

@vanroekel
Copy link
Contributor

I generated the layers for @proteanplanet -- here are the layer thicknesses from that invocation of the script

1.98312923 2.22519441 2.49685395 2.80181737 3.1442291
3.52855849 3.95992628 4.44421212 4.98772461 5.59774398
6.28240812 7.05070601 7.91279578 8.87999147 9.96496251
11.18181656 12.54628046 14.07564869 15.78925496 17.70826202
19.855847 22.25743896 24.94034081 27.9336851 31.26825453
34.9755951 39.08744573 43.63426116 48.64342975 54.13695011
60.12858277 66.61998041 73.5971205 81.02584967 88.84911568
96.98450166 105.32498239 113.74241952 122.09422308 130.23325689
138.01922673 145.32973767 152.06928836 158.1743376 163.61443548
168.38947637 172.52432948 176.06218087 179.05781446 181.57172959
183.66541283 185.39799053 186.82412992 187.99284603 188.94713296
189.72400846 190.35491212 190.86625967 191.28003803 191.61442574
191.88437023 192.10210492 192.27760581 192.41898635

@vanroekel vanroekel closed this Mar 30, 2020
@vanroekel vanroekel reopened this Mar 30, 2020
@vanroekel
Copy link
Contributor

sorry, accidentally clicked closed.

I was going to say that I don't have the parameters I used anymore. but your graph looks close to what I post here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xylar, I've only tested the QU240 right now, but this file changes all of them. Is it best to call the python script as an command-line executable here? That's what I'm most familiar with.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is fine.

@mark-petersen
Copy link
Contributor Author

I generated the layers for @proteanplanet -- here are the layer thicknesses from that invocation of the script
1.98312923 2.22519441 2.49685395 2.80181737 3.1442291
3.52855849 3.95992628 4.44421212 4.98772461 5.59774398
6.28240812 7.05070601 7.91279578 8.87999147 9.96496251
11.18181656 12.54628046 14.07564869 15.78925496 17.70826202
19.855847 22.25743896 24.94034081 27.9336851 31.26825453
34.9755951 39.08744573 43.63426116 48.64342975 54.13695011
60.12858277 66.61998041 73.5971205 81.02584967 88.84911568
96.98450166 105.32498239 113.74241952 122.09422308 130.23325689
138.01922673 145.32973767 152.06928836 158.1743376 163.61443548
168.38947637 172.52432948 176.06218087 179.05781446 181.57172959
183.66541283 185.39799053 186.82412992 187.99284603 188.94713296
189.72400846 190.35491212 190.86625967 191.28003803 191.61442574
191.88437023 192.10210492 192.27760581 192.41898635

@vanroekel thanks for the values. This new one looks extremely close:
[ 1.97697012 2.1874616 2.42467604 2.69195132 2.99262391
3.33114193 3.71195067 4.13949159 4.62154066 5.16363904
5.77354315 6.45899347 7.22993359 8.09738692 9.07344281
10.17123718 11.40492584 12.79186606 14.34923108 16.09836972
18.06247351 20.26532146 22.7343817 25.49830612 28.58872035
32.03856028 35.88239971 40.15328066 44.88357416 50.10222321
55.83163801 62.08427362 68.85899273 76.13741704 83.87787262
92.01346542 100.44848303 109.06282554 117.71363083 126.2458942
134.5039678 142.34350209 149.64357922 156.31506951 162.30477184
167.59450648 172.19671331 176.14787945 179.50099529 182.31795284
184.66449925 186.60513888 188.20052864 189.50552546 190.5686493
191.43188142 192.13087372 192.69560719 193.15107425 193.51786304
193.81291227 194.05002642 194.2404337 194.3932398 ]

@proteanplanet
Copy link

@vanroekel I'll run this through my scripts later today and post the results here and on Confluence.

Comment on lines 6 to 12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These kinds of subprocess calls are not working well with the MPI versions of the COMPASS environment. It would be better to make this a function and call it that way. In general, calling python scripts from other python scripts with subprocess is not a good practice.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mark-petersen, do you want me to make these changes or do you want to do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it should look like this instead?

include make_vertical_grid

make_vertical_grid(arg1, arg2, ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that one is done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should look like this:

#!/usr/bin/env python
from make_vertical_grid import create_vertical_grid


# Standard 64 layer vertical grid
create_vertical_grid(bottom_depth=5500, nz=64, dz1_in=2.0, dz2_in=200.0,
                     plot_vertical_grid=True, maxit=1000, epsilon=1e-2,
                     outfile='vertical_grid.nc')

@mark-petersen
Copy link
Contributor Author

OK, I've tested with QU240, QU240wISC, and EC60to30. I am confident the COMPASS a scripts are all working.

@proteanplanet
Copy link

@vanroekel - An assorted set of comparisons between 60-, 64- and 80-levels:
64-level-grid_1
64-level-grid_2
64-level-grid_3
64-level-grid_4
64-level-grid_5
64-level-grid_6

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think links like this are needed for a lot more test cases, right?

  • CUSP12
  • CUSP8
  • QU60
  • SO60to10wISC
  • SOQU60to15 (is this even a configuration we want to keep?)

Copy link
Collaborator

@xylar xylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mark-petersen and @vanroekel, I've spent time today trying to understand the algorithm by which layer thicknesses are selected and I really can't understand it. I would appreciate going through it carefully with @vanroekel if we want to keep the algorithm as it is but I would suggest switching to something simpler and easier to control, where we just use the root finder from scipy. I will post a suggested alternative algorithm in a gist below.

@mark-petersen
Copy link
Contributor Author

@xylar after today's progress, is it OK if we merge this before #450? Then I can have a big E3SM 'COMPASS only' PR, and take the Fortran PRs in smaller bunches for E3SM. But if you still prefer to wait on this, I'll do it after #450.

@mark-petersen
Copy link
Contributor Author

BTW, I will still address your remaining comments above on this PR.

@xylar
Copy link
Collaborator

xylar commented Mar 31, 2020

Thought a phone call would be easier...

My concern about merging this is whether it makes it difficult to (temporarily) go back to the 60-level mesh for the EC60to30wISC initial condition that's currently our highest priority. I guess it shouldn't be hard to do that, though, right?

@xylar
Copy link
Collaborator

xylar commented Apr 1, 2020

During our meeting today, @maltrud suggested setting the maximum depth to 6000 or 6500 m. Here is a comparison of 5500 (black) with 6500 (red).

vertical_grid_5500_6500

The lower right panel is just a zoom in on the upper right.

mark-petersen and others added 8 commits April 1, 2020 13:48
This is a more straight-forward root finding approach using
scipy.  It finds a characteristic lengh scale `delta` over which
layer thickenesses vary from `dz1` a the surface to `dz2` at
`z --> -infinity` such that the sum of the layer thicknesses
hits the target bottom depth in the given number of layers.

Docstrings and formatting have been improved.
remove link for config_initial_state.xml
copy ocean/develop version of config_initial_state.xml in
@mark-petersen mark-petersen force-pushed the ocean/vertical_coordinate_script branch from 5039d7c to 80630e9 Compare April 1, 2020 23:08
@mark-petersen
Copy link
Contributor Author

Rebased on ocean/develop. Old 60 layer case is still available, but default is now the 64 layer case. I changed the test QU240 to 16 layers for speed.

bottom_depth=6000,
min_layer_thickness=2.,
max_layer_thickness=210.,
plot_vertical_grid=True,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the comments at the meeting today I set the 64-layer bottom depth to 6000m, varying from 2m to 210m.

@mark-petersen
Copy link
Contributor Author

mark-petersen commented Apr 1, 2020

Here is the auto-generated plot:
vertical_grid
The raw numbers are here:
https://gist.github.com/mark-petersen/f4b9617040783d17c1fd65c2f02ee7bb
and file on turquoise at:
/lustre/scratch4/turquoise/mpeterse/runs/200401_vertical_coordinate_script/ocean/global_ocean/EC60to30/init/initial_state/vertical_grid.nc

@mark-petersen
Copy link
Contributor Author

EC60to30 with 64 levels. This is the new plot that is produced at the end of the initial_state step:
initial_state

@mark-petersen mark-petersen merged commit cd5d9f1 into MPAS-Dev:ocean/develop Apr 2, 2020
@mark-petersen mark-petersen deleted the ocean/vertical_coordinate_script branch April 2, 2020 04:48
mark-petersen added a commit that referenced this pull request Apr 2, 2020
Previously, the vertical coordinate (layer depths) was read from a file
when generating initial conditions in COMPASS. This adds a script with
input parameters and adds it to the COMPASS init sequence. This will be
used to create a 64-layer domain for the EC60to30 and others right now.
mark-petersen added a commit that referenced this pull request Apr 2, 2020
This step inadvertently got replaced with the non-ice-shelf-cavity
version in #495.
xylar added a commit to xylar/MPAS-Model that referenced this pull request Apr 9, 2020
This change is needed because of a recent modification (MPAS-Dev#495) to
`build_mesh.py`
caozd999 pushed a commit to caozd999/MPAS-Model that referenced this pull request Jan 14, 2021
…evelop

Previously, the vertical coordinate (layer depths) was read from a file
when generating initial conditions in COMPASS. This adds a script with
input parameters and adds it to the COMPASS init sequence. This will be
used to create a 64-layer domain for the EC60to30 and others right now.
caozd999 pushed a commit to caozd999/MPAS-Model that referenced this pull request Jan 14, 2021
This change is needed because of a recent modification (MPAS-Dev#495) to
`build_mesh.py`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants