---
# System prepended metadata

title: Torus grid
tags: [icon4py]

---

# Torus


Torus grid files are generated by
https://gitlab.dkrz.de/mpim-sw/grid-generator/-/blob/master/src/grid_generator/mo_create_torus_grid.f90?ref_type=heads




## Sphere
whereas the icosahedron grid files are normally generated by DWD's `gridgen` in DWD `icontools`. (standalone or web interface https://webservice.dwd.de/cgi-bin/spp1167/webservice.cgi) or downloadable here (http://icon-downloads.mpimet.mpg.de/dwd_grids.xml)

This leads to the grid file being quite different. There are some data arrays which are not present in the Torus files and some of them have different units.

Torus is doubly periodic flat plane. It contains equally sized squares, see Icon Tutorial 2.1.9. 

### differences
- Geometry: Obviousely the geometry is different, since the torus has no curvature. In Icon this is in `t_grid_geometry_info`in `mo_grid_geometry_info.f89`. Which contains some mean values for geometrical quantities. In case of the sphere those are computed in ICON. The torus grid files they are attributes in the grid file. Computation is done in [grid_generator](https://gitlab.dkrz.de/mpim-sw/grid-generator/-/blob/master/src/grid_generator/mo_create_torus_grid.f90?ref_type=heads)

    - mean_edge_length: edge_length = x_length / num_cols_x (there is some circular computation, eventually these depend on a namelist)??
    
    - mean_cell_area: edge_length ^2 * sqrt(3) / 2 == edge_length^2 * sqrt(0.1875)
   
    - mean_dual_edge_length: edge_length * (1. / sqrt(3.0)
    
    
    
    
   
- interpolation coefficients `mo_intp_coeffs.f90`: a handful of interpolation coefficients get computed differently.

### outline
```mermaid
classDiagram
direction TB

class GridType{
+ SPHERE
+ TORUS
}
<<Enumeration>> GridType

class GlobalGridParams{
+ int num_cells
+ GridType gridType
}
<<abstract>> GlobalGridParams

class IcosahedronParams{
+ gridtype = GridType.SPHERE
+ grid_root
+ grid_level
}

class TorusParams{
    gridType = GridType.TORUS
}

GlobalGridParams <|-- IcosahedronParams
GlobalGridParams <|-- TorusParams
```
```mermaid
classDiagram

class CellParams{
+ Field[Dims[CellDim], float] cell_center_lat
+ Field[Dims[CellDim], float] cell_center_lon
+ Field[Dims[CellDim], float] areas
+ float mean_cell_area
+ float length_rescale_factor = 1.0

+ __init__(lat, lon, areas, mean_area, scale_factor)
+  static CellParams from_global_num_cells(lat, lon, areas, global_num_cells, scale_factor)
}

```



## TODOs

- clarify with Jacopo what exactly he needs

- grid files: they are quite different (I assume that the spherical grids we use are generated from the DWD icontools.
    -  There are some additional fields in the torus grid, 
    -  some fields have different units 
    -  

### Naming

use **global** vs **local** in the context of domain decomposition

use **limited_area** vs **icosahedron** vs **torus** and total in the context of geometry and domain 

total_number_of_cells_on_sphere
number_of_cells_on_icosahedron
number_of_cells_on_torus


