Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UpdateTbcStochastic.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 !******************************************************************************
24 !
25 ! Purpose: update values for Stochastic TBC
26 !
27 ! Description: none.
28 !
29 ! Input: pointer to TBC, substep dt
30 !
31 ! Output: modifies TBC data
32 !
33 ! Notes:
34 !
35 ! * Example input section:
36 !
37 !-----
38 ! # TBC_STOCHASTIC
39 ! PEUL_INJECT FRAC2 ! BC and variable to which TBC applies
40 ! BLOCK 0 0 ! applies to block ... (0 0 = to all)
41 ! PATCH 0 0 ! applies to patch ... (0 0 = to all patches from blocks)
42 ! ONTIME 5.e-5 ! time to start using this TBC
43 ! OFFTIME 1.e-2 ! time to stop using this TBC
44 ! AMP 0.2 ! standard deviation of log of the stochastic factor
45 ! TIMECOR 1.e-4 ! integral time scale of autocorrelation
46 ! SHAPE 1.0 ! shape: recommended value = 1.0 is default
47 ! MINCUT 0.2 ! minimal value for stochastic factor (< 0 for none)
48 ! MAXCUT 5.0 ! maximal value for stochastic factor (< 0 for none)
49 ! #
50 !-----
51 !
52 ! * The value used in the boundary condition is the one input times the factor
53 ! produced by this routine, provided OFFTIME <= t <= ONTIME. The factor is
54 ! different for every cell, and is always positive.
55 !
56 ! * The values produced are continuous and, in fact, smooth in time. They are
57 ! independent in space.
58 !
59 ! * TIMECOR is the decorrelation time scale of the process.
60 !
61 ! * SHAPE determines what the autocorrelation function looks like. For
62 !
63 ! 0 <= SHAPE < 1, R(t) is overdamped,
64 ! SHAPE = 1, R(t) is critically damped,
65 ! SHAPE > 1, R(t) is underdamped (i.e., decaying but oscillatory).
66 !
67 ! * For numerical reasons, the restriction 0.1 <= SHAPE <= 10 is imposed.
68 !
69 !******************************************************************************
70 !
71 ! $Id: UpdateTbcStochastic.F90,v 1.3 2008/12/06 08:44:10 mtcampbe Exp $
72 !
73 ! Copyright: (c) 2001 by the University of Illinois
74 !
75 !******************************************************************************
76 
77 SUBROUTINE updatetbcstochastic( region,tbc,dt )
78 
79  USE moddatatypes
80  USE modbndpatch, ONLY : t_tbcvalues
81  USE moddatastruct, ONLY : t_region
82  USE modglobal, ONLY : t_global
83  USE modparameters
84  USE modrandom, ONLY : randuniform
85  USE moderror
86  IMPLICIT NONE
87 
88 ! ... parameters
89  TYPE(t_region), INTENT(INOUT) :: region
90  TYPE(t_tbcvalues), INTENT(INOUT) :: tbc
91 
92  REAL(RFREAL), INTENT(IN) :: dt
93 
94 ! ... local variables
95  REAL(RFREAL) :: dtn,fac,e0,e1,s0,s1,ts,a0,b0,a1,b1,del
96  REAL(RFREAL), POINTER :: params(:), bvals(:,:)
97 
98  TYPE(t_global), POINTER :: global
99 
100 !******************************************************************************
101 
102  global => region%global
103 
104  CALL registerfunction( global,'UpdateTbcStochastic',&
105  'UpdateTbcStochastic.F90' )
106 
107  bvals => tbc%bvals
108  params => tbc%params
109 
110  dtn = dt/params(tbcdat_timecor)
111  fac = -2.0_rfreal/params(tbcdat_shape)
112 
113  e0 = exp(fac*dtn*dtn)
114  e1 = exp(2.0_rfreal*fac*dtn)
115  s0 = sqrt(1.0_rfreal - e0*e0)
116  s1 = sqrt(1.0_rfreal - e1*e1)
117  ts = 0.5_rfreal * params(tbcdat_timecor) * sqrt(params(tbcdat_shape))
118 
119  a0 = e0
120  b0 = s0 * ts
121  a1 = -s0*e1 / (ts*e0)
122  b1 = e1/e0
123  del = sqrt(12.0_rfreal) * params(tbcdat_amp) * s1 / ts
124 
125  CALL randuniform(bvals(tbcsto_factor,:),region%randData)
126 
127  bvals(tbcsto_val, :) = a0*bvals(tbcsto_val,:) + b0*bvals(tbcsto_dval,:)
128  bvals(tbcsto_dval,:) = a1*bvals(tbcsto_val,:) + b1*bvals(tbcsto_dval,:) + &
129  del * (bvals(tbcsto_factor,:) - 0.5_rfreal)
130  bvals(tbcsto_factor,:) = exp(bvals(tbcsto_val,:) - &
131  0.5_rfreal * params(tbcdat_amp)**2 )
132  IF (params(tbcdat_mincut) >= 0._rfreal) &
133  bvals(tbcsto_factor,:) = max(params(tbcdat_mincut),bvals(tbcsto_factor,:))
134  IF (params(tbcdat_maxcut) >= 0._rfreal) &
135  bvals(tbcsto_factor,:) = min(params(tbcdat_maxcut),bvals(tbcsto_factor,:))
136 
137 ! finalize --------------------------------------------------------------------
138 
139  CALL deregisterfunction( global )
140 
141 END SUBROUTINE updatetbcstochastic
142 
143 !******************************************************************************
144 !
145 ! RCS Revision history:
146 !
147 ! $Log: UpdateTbcStochastic.F90,v $
148 ! Revision 1.3 2008/12/06 08:44:10 mtcampbe
149 ! Updated license.
150 !
151 ! Revision 1.2 2008/11/19 22:17:24 mtcampbe
152 ! Added Illinois Open Source License/Copyright
153 !
154 ! Revision 1.1 2004/12/01 16:52:12 haselbac
155 ! Initial revision after changing case
156 !
157 ! Revision 1.8 2003/11/21 22:33:10 fnajjar
158 ! Updated Random Number Generator
159 !
160 ! Revision 1.7 2003/06/10 22:52:48 jferry
161 ! Added documentation for input section
162 !
163 ! Revision 1.6 2003/05/15 02:57:02 jblazek
164 ! Inlined index function.
165 !
166 ! Revision 1.5 2003/02/17 19:31:11 jferry
167 ! Implemented portable random number generator ModRandom
168 !
169 ! Revision 1.4 2002/09/27 00:57:09 jblazek
170 ! Changed makefiles - no makelinks needed.
171 !
172 ! Revision 1.3 2002/09/25 18:29:57 jferry
173 ! simplified TBC parameter lists
174 !
175 ! Revision 1.2 2002/09/20 22:22:35 jblazek
176 ! Finalized integration into GenX.
177 !
178 ! Revision 1.1 2002/09/17 13:43:00 jferry
179 ! Added Time-dependent boundary conditions
180 !
181 !******************************************************************************
182 
183 
184 
185 
186 
187 
188 
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
double sqrt(double d)
Definition: double.h:73
subroutine updatetbcstochastic(region, tbc, dt)
subroutine randuniform(a, rdata)
Definition: ModRandom.F90:135
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
subroutine deregisterfunction(global)
Definition: ModError.F90:469