sources_planetheating.f90
Go to the documentation of this file.
1!#############################################################################
2!# #
3!# fosite - 3D hydrodynamical simulation program #
4!# module: sources_planetheating.f90 #
5!# #
6!# Copyright (C) 2013-2024 #
7!# Jannes Klee <jklee@astrophysik.uni-kiel.de> #
8!# Tobias Illenseer <tillense@astrophysik.uni-kiel.de> #
9!# #
10!# This program is free software; you can redistribute it and/or modify #
11!# it under the terms of the GNU General Public License as published by #
12!# the Free Software Foundation; either version 2 of the License, or (at #
13!# your option) any later version. #
14!# #
15!# This program is distributed in the hope that it will be useful, but #
16!# WITHOUT ANY WARRANTY; without even the implied warranty of #
17!# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
18!# NON INFRINGEMENT. See the GNU General Public License for more #
19!# details. #
20!# #
21!# You should have received a copy of the GNU General Public License #
22!# along with this program; if not, write to the Free Software #
23!# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
24!# #
25!#############################################################################
26!----------------------------------------------------------------------------!
40!----------------------------------------------------------------------------!
69!----------------------------------------------------------------------------!
79 USE common_dict
80 IMPLICIT NONE
81 !--------------------------------------------------------------------------!
82 PRIVATE
83 CHARACTER(LEN=32), PARAMETER :: source_name = "heating of planetary atmosphere"
84 REAL, PARAMETER :: au = 1.49597870691e+11 ! astr. unit [m] !
85 !--------------------------------------------------------------------------!
87 TYPE(marray_base), ALLOCATABLE &
88 :: cos1,sin1
89 REAL :: radflux
90 REAL :: albedo
91 REAL :: sm_axis
92 REAL :: excentricity
93 REAL :: true_anomaly
94 REAL :: omegasun
95 REAL :: year
96 REAL :: theta0, phi0
97 CONTAINS
98 PROCEDURE :: initsources
99! PROCEDURE :: SetOutput
100 PROCEDURE :: infosources
101 PROCEDURE :: updatecooling => updateplanetheating ! overwrite inherited method from sources_cooling
102 final :: finalize
103 END TYPE
104 PUBLIC :: &
105 ! types
107 !--------------------------------------------------------------------------!
108
109CONTAINS
110
111
113 SUBROUTINE initsources(this,Mesh,Physics,Fluxes,config,IO)
118 IMPLICIT NONE
119 !------------------------------------------------------------------------!
120 CLASS(sources_planetheating), INTENT(INOUT) :: this
121 CLASS(mesh_base), INTENT(IN) :: Mesh
122 CLASS(physics_base), INTENT(IN) :: Physics
123 CLASS(fluxes_base), INTENT(IN) :: Fluxes
124 TYPE(dict_typ), POINTER :: config,IO
125 INTEGER :: stype
126 !------------------------------------------------------------------------!
127 INTEGER :: err
128 !------------------------------------------------------------------------!
129 CALL getattr(config, "stype", stype)
130 CALL this%InitSources_base(stype,source_name)
131
132 CALL this%Info("############################ ATTENTION ############################")
133 CALL this%Warning("sources_planetheating::InitSources","Untested module, use with care!")
134
135 ! some sanity checks
136 SELECT TYPE (phys => physics)
137 CLASS IS(physics_euler)
138 ! do nothing
139 CLASS DEFAULT
140 CALL this%Error("InitSources_planetheating","physics not supported")
141 END SELECT
142
143 SELECT TYPE (const => physics%constants)
144 CLASS IS(constants_si)
145 ! do nothing
146 CLASS DEFAULT
147 CALL this%Error("InitSources_planetheating","only SI units supported")
148 END SELECT
149
150 ALLOCATE(this%Q,this%cos1,this%sin1)
151 this%Q = marray_base()
152 this%cos1 = marray_base(2) !TODO check if 2 is really necessary
153 this%sin1 = marray_base(2) !TODO check if 2 is really necessary
154
155 ! Courant number, i.e. safety factor for numerical stability
156 CALL getattr(config, "cvis", this%cvis, 0.1)
157 ! intensity of the planets star at 1 AU
158 CALL getattr(config, "radflux", this%radflux)
159 ! albedo of the planet
160 CALL getattr(config, "albedo", this%albedo)
161 ! nummerical excentricity
162 CALL getattr(config, "excentricity", this%excentricity, 0.0)
163 ! semi-major-axis
164 CALL getattr(config, "semimajoraxis", this%sm_axis)
165 ! day-night omega
166 CALL getattr(config, "omegasun", this%omegasun, 0.0)
167 ! year
168 CALL getattr(config, "year", this%year)
169 ! beginning points
170 CALL getattr(config, "theta0", this%theta0, 0.0)
171 CALL getattr(config, "phi0", this%phi0, 0.0)
172
173 SELECT TYPE (mgeo => mesh%Geometry)
174 TYPE IS(geometry_spherical)
175 ! TODO: ATTENTION CHECK THAT THIS REGION IS CORRECT AFTER TRANSITION TO NEW FOSITE
176 this%cos1%data4d(:,:,:,1) = cos(mesh%bcenter(:,:,:,2))
177! this%cos1(:,:,2) = COS(Mesh%bcenter(:,:,2))
178 this%sin1%data4d(:,:,:,1) = sin(mesh%bcenter(:,:,:,2))
179! this%sin1(:,:,2) = SIN(Mesh%bcenter(:,:,2))
181 ! TODO: ATTENTION CHECK THAT THIS REGION IS CORRECT AFTER TRANSITION TO NEW FOSITE
182 this%cos1%data4d(:,:,:,1) = cos(mesh%bcenter(:,:,:,1))
183! this%cos1(:,:,2) = COS(Mesh%bcenter(:,:,2))
184 this%sin1%data4d(:,:,:,1) = sin(mesh%bcenter(:,:,:,1))
185! this%sin1(:,:,2) = SIN(Mesh%bcenter(:,:,2))
186 CLASS DEFAULT
187 CALL this%Error("InitSources_planetheating","only spherical geometry allowed")
188 END SELECT
189
190 ! set initial time < 0
191 ! TODO: Check were this time is set? Is it correct? Why not timedisc time?
192 this%time = -1.0
193
194 ! initialize arrays
195 this%Q%data1d(:) = 0.0
196
197 ! register ouput arrays
198 CALL this%SetOutput(mesh,config,io)
199
200 ! call InitSources in base
201 CALL this%InfoSources(mesh)
202 END SUBROUTINE initsources
203
204 SUBROUTINE setoutput(this,Mesh,config,IO)
205 IMPLICIT NONE
206 !------------------------------------------------------------------------!
207 CLASS(sources_planetheating), INTENT(INOUT) :: this
208 CLASS(mesh_base), INTENT(IN) :: Mesh
209 TYPE(dict_typ), POINTER :: config,IO
210 !------------------------------------------------------------------------!
211 INTEGER :: valwrite
212 !------------------------------------------------------------------------!
213 ! register heating source term for output
214 CALL getattr(config, "output/Qstar", valwrite, 0)
215 IF (valwrite .EQ. 1) &
216 CALL setattr(io, "Qstar", &
217 this%Q%data3d(mesh%IMIN:mesh%IMAX,mesh%JMIN:mesh%JMAX,mesh%KMIN:mesh%KMAX))
218 END SUBROUTINE setoutput
219
220
221 SUBROUTINE infosources(this,Mesh)
222 IMPLICIT NONE
223 !------------------------------------------------------------------------!
224 CLASS(sources_planetheating), INTENT(IN) :: this
225 CLASS(mesh_base), INTENT(IN) :: Mesh
226 !------------------------------------------------------------------------!
227 CHARACTER(LEN=32) :: param_str
228 REAL :: tmp_out
229 REAL, PARAMETER :: AU = 1.49597870691e+11 ! astr. unit [m] !
230 !------------------------------------------------------------------------!
231 WRITE (param_str,'(ES10.2)') this%year/(3.6e3*24*365.2425)
232 CALL this%Info(" sid. year: " // trim(param_str) // " yr")
233
234 IF (abs(this%omegasun).GT.tiny(this%omegasun)) THEN
235 WRITE (param_str,'(ES10.2)') abs(1./(this%omegasun*3.6e3*24.0))
236 CALL this%Info(" day: " // trim(param_str) // " d")
237 ELSE
238 CALL this%Info(" day: " // "infinite (tidally locked)")
239 END IF
240
241 WRITE (param_str,'(ES10.2)') this%sm_axis/au
242 CALL this%Info(" semi-major axis: " // trim(param_str) // " au")
243
244 WRITE (param_str,'(ES10.2)') this%excentricity
245 CALL this%Info(" excentricity: " // trim(param_str))
246
247 WRITE (param_str,'(ES10.2)') this%sm_axis/au*(1.+0.5*this%excentricity**2)
248 CALL this%Info(" mean distance: " // trim(param_str) // " au")
249 END SUBROUTINE infosources
250
251
289 SUBROUTINE updateplanetheating(this,Mesh,Physics,time,pvar)
291 USE gravity_binary_mod, ONLY : kepler
292 IMPLICIT NONE
293 !------------------------------------------------------------------------!
294 CLASS(sources_planetheating), INTENT(INOUT) :: this
295 CLASS(mesh_base), INTENT(IN) :: Mesh
296 CLASS(physics_euler), INTENT(IN) :: Physics
297 REAL, INTENT(IN) :: time
298 CLASS(statevector_euler), INTENT(IN) :: pvar
299 !------------------------------------------------------------------------!
300 INTEGER :: i,j,k
301 REAL :: theta2,phi1,phi2,r,mean_anomaly,true_anomaly
302 !------------------------------------------------------------------------!
303 ! heating by the star
304 IF (time.NE.this%time) THEN
305 ! calculate the new distance (and true anomaly) by solving Kepler's equation
306 CALL kepler(time,this%year,this%excentricity,this%sm_axis,r,true_anomaly)
307
308 DO k=mesh%KMIN,mesh%KMAX
309 DO j=mesh%JMIN,mesh%JMAX
310 DO i=mesh%IMIN,mesh%IMAX
311 !--------------------------------------------------------------!
312 phi1=mesh%bcenter(i,j,k,2) + 2.*pi*this%omegasun*this%time
313 ! transformation
314 theta2 = acos(this%cos1%data4d(i,j,k,1)*cos(this%theta0*&
315 cos(2*pi*this%time/this%year)) + &
316 this%sin1%data4d(i,j,k,1)*sin(this%theta0*&
317 cos(2*pi*this%time/this%year))*cos(phi1-this%phi0))
318
319 ! modulo function to prevent phi2>2*PI,phi2<0
320 phi2 = modulo(atan2(this%sin1%data4d(i,j,k,1)*sin(phi1-this%phi0),&
321 (-this%cos1%data4d(i,j,k,1)*sin(this%theta0*cos(2.*pi*this%time/&
322 this%year)) + this%sin1%data4d(i,j,k,1)*cos(phi1-this%phi0)*&
323 cos(this%theta0*cos(2*pi*this%time/this%year)))),2*pi)
324
325 ! calculate heating source !
326 !--------------------------------------------------------------!
327 IF (phi2.LE.pi/2..OR.phi2.GE.3./2.*pi) THEN
328 ! for sin,cos have a look at spherical trigonometry
329 ! the albedo can contain things like scattering etc. (not implemented),
330 ! radflux is given at 1 AU
331 this%Q%data3d(i,j,k) = (1.-this%albedo)*this%radflux * (au/r)**2 &
332 *sin(theta2)*cos(phi2)
333 ELSE
334 this%Q%data3d(i,j,k) = 0.0
335 END IF
336 END DO
337 END DO
338 END DO
339 this%time = time
340 END IF
341 END SUBROUTINE updateplanetheating
342
343
345 SUBROUTINE finalize(this)
346 IMPLICIT NONE
347 !------------------------------------------------------------------------!
348 TYPE(sources_planetheating), INTENT(INOUT) :: this
349 !------------------------------------------------------------------------!
350 DEALLOCATE(this%cos1,this%sin1)
351 ! this%Q is deallocated in parent class destructor
352 END SUBROUTINE finalize
353
Dictionary for generic data types.
Definition: common_dict.f90:61
module for SI units and physical constants
base module for numerical flux functions
Definition: fluxes_base.f90:39
defines properties of a 3D spherical mesh
defines properties of a 3D spherical mesh
source terms module for gravitational acceleration due to two pointmasses
pure subroutine, public kepler(time, period, excent, semax, r, phi)
solve Kepler-Equation and return new distance r and position angle phi
Basic fosite module.
subroutine finalize(this)
Destructor of logging_base class.
base class for mesh arrays
Definition: marray_base.f90:36
derived class for compound of mesh arrays
basic mesh module
Definition: mesh_base.f90:72
subroutine setoutput(this, config, IO)
Setup mesh fields for i/o.
Definition: mesh_base.f90:828
Basic physics module.
physics module for 1D,2D and 3D non-isothermal Euler equations
generic source terms module providing functionaly common to all source terms
source terms module for simple optically thin cooling
subroutine initsources(this, Mesh, Physics, Fluxes, config, IO)
subroutine updatecooling(this, Mesh, Physics, time, pvar)
Updates the cooling function at each time step.
character(len=32), parameter source_name
heating of a planet by a star
subroutine updateplanetheating(this, Mesh, Physics, time, pvar)
Updates the heating for a given time.
subroutine infosources(this, Mesh)
basic mesh array class
Definition: marray_base.f90:69
mesh data structure
Definition: mesh_base.f90:122