Sorry for the stupid question, but I have been unable to answer it even after wasting time googleing for a while... I know there are several climate-changes scenarios, and I know the several climatic databases offering surfaces (rasters) with those scenarios. However, I want to try some calculations on my own, for which I am looking for the mathematics behind these models (the different scenarios) or some code (preferably in R). Any suggestion?
Full scale climate models
The atmospheric climate simulations that are presented in the IPCC reports are performed by quite large and complex models. Running these models needs a "supercomputer" (high performance cluster). Additionally, certain "forcing data" and "boundary conditions" are needed.
Boundary conditions are the top of the atmosphere and the Earth's surface/oceans. Partly, atmospheric climate model simulations are directly coupled to ocean model simulations. This makes the models even larger and harder to setup/run. "Forcing data" means thinks like CO2 emissions, emissions of particulate matter, solar radiation ... .
Having said that: it is quite unrealistic to setup und run a "real" climate model just for fun.
Further reading on recent climate modeling activities
Simulation results of the couple model intercomparison project (CMIP) form the basis for the IPCC reports. The CMIP Phase 6 (CMIP6) simulations form the basis of the most recent IPCC reports. There is an overview paper of CMIP6 which might indicate how large the overhead for running "real" climate models in a comparable way is (Eyring et al., 2016).
One of the models that were used for the CMIP5 and CMIP6 simuations was the MPI-ESM model. An overview of this model is given in Giorgette et al. (2013). Detailed descriptions are available in this special issue.
There are several more models used in CMIP5 and CMIP6. The MPI-ESM is just an example.
Climate models made for training
There are some simple climate models that are made for students and which are based on a few governing equations. Seems models show the general features of climate models but can be run on a normal end-user computer. One of these models is the "Monash simple climate model". An instance of that model which can be run via a web-GUI is available here. There is a documentation available in which you will find links to a publication describing the model and to a repository to download the source code.
There is another climate model made for training which is called Planet Simulator. Download details and documentation are offered on that web page.
You might try a latitudinally-resolved climate model. These were invented in 1969 to see how global warming or cooling moved the boundaries of the polar caps. One result is that a slight decrease in the Solar constant glaciates the Earth; that's because the models don't include the carbonate-silicate cycle which stabilizes Earth's temperature in the long run. But for examining small changes it might be okay.
The basic equation is one of power balance (usually incorrectly called "energy balance"):
Qi (1 - Ai) = A + B Ti + C(Ti - T)
Here Qi is the insolation, averaged over the year, in a given latitude band, band i--you need a lot of spherical astronomy and trig to figure this out, but some articles (e.g. Warren and Schneider 1979 or Chylek and Coakley 1975) have precalculated tables you can use. Ai is the albedo in that band--you can set this to flip from a high value (bright, icy) to a low value (dark, uncovered) when temperature goes over a critical value, like 273 K. The whole left-hand side of the equation, then, is the solar power absorbed in that climate band.
A + B Ti is the infrared power emitted by that band to space. A and B are constants (A is not the albedo Ai), and Ti is the band's temperature--normally you start out with an isothermal Earth and then iterate until the simulation stabilizes. Values for A and B vary somewhat in the literature, but in a recent paper I used A = 214.5 W m^-2 and B = 1.57 W m^-2 K^-1.
The last term is the energy moved from one band to another, in a very simple (read "crude") "diffusion" model. C is a constant, Ti is and temperature, and T is the average temperature of the whole globe (I'll tell you how to calculate that in a minute). Again, values for C vary. Recently I used C = 3.74 W m^-2 K^-1.
You can find the mean global albedo or temperature or what-have-you by multiplying the zonal values by the zonal area fraction and adding up all the figures. You find the fraction of a hemisphere's area by subtracting the sine of the more equatorial boundary from the sine of the more polar boundary. For instance, the area of a hemisphere between 30 and 40 degrees is sin(40) - sin(30) = 0.1428.
P. Chýlek, J.A. Coakley, Jr. J. Atmos. Sci. 32, 675-679 (1975).
S.G. Warren, S.H. Schneider. J. Atmos. Sci. 36, 1377-1391 (1979).