Presentation is loading. Please wait.

Presentation is loading. Please wait.

Evolution from VBA V1 to V2 (Numerics)

Similar presentations


Presentation on theme: "Evolution from VBA V1 to V2 (Numerics)"— Presentation transcript:

1 Evolution from VBA V1 to V2 (Numerics)

2 Main program: Version V1.2
Do While ctrl.t < ctrl.tend 'Sets new time and zeros coefficients ctrl.t = ctrl.t + ctrl.dt ctrl.TimeDays = ctrl.t / 86400 Call ZerosCoeffs(Coef, gr) ' Call LightUpdate(Light, ctrl, gr, Pr) ' If Not (Pr.Temperature.Calc_As.Method = "Evolution") Then ' Call CalcTempIfnotEvolution(Pr.Temperature, gr, ctrl) ' End If ' Performs transport Call CoefTransport(flow, gr.NC, ctrl, Coef) If (ctrl.Explicit) Then Call ExpTransport(Pr.Generic, Coef, gr.NC) Else Main program: Version V1.2 Else MsgBox ("Implicit not programed in this version") End End If ' Performs discharges Call ApplyDischarges(Pr.Generic, gr, ctrl.dt) ' Call ApplyDischarges(Pr.Temperature, gr, ctrl.dt) 'Updates concentrations with sources and sinks in Phyto, Zoo and Detritus properties 'and Nutrient property If (ctrl.Explicit) Then Call ExpSinksGeneric(Pr.Generic, gr.NC, ctrl.dt) Call ImpSinksGeneric(Pr.Generic, gr.NC, ctrl.dt)

3 Sub CoefTransport(flow As Flow_properties, NC As Integer, ctrl As Controls, Coef As Equation_Coef)
Dim I As Integer If ctrl.Diffusion Then ……… End If If ctrl.Advection Then If ctrl.AdvType = "upwind" Then ' Advection Upwind …….. ElseIf ctrl.AdvType = "central" Then For I = 2 To NC - 1 Coef.LeftCoef(I) = Coef.LeftCoef(I) + flow.CourantNr / 2 Coef.RigthCoef(I) = Coef.RigthCoef(I) - flow.CourantNr / 2 Next

4 ' Even with central differences upwind has to be used at the boundaries
If flow.Velocity > 0 Then Coef.LeftCoef(NC) = Coef.LeftCoef(NC) + flow.CourantNr Coef.CenterCoef(NC) = Coef.CenterCoef(NC) - flow.CourantNr Coef.LeftCoef(1) = Coef.LeftCoef(1) + flow.CourantNr Coef.CenterCoef(1) = Coef.CenterCoef(1) - flow.CourantNr Else Coef.CenterCoef(1) = Coef.CenterCoef(1) + flow.CourantNr Coef.RigthCoef(1) = Coef.RigthCoef(1) - flow.CourantNr Coef.CenterCoef(NC) = Coef.CenterCoef(NC) + flow.CourantNr Coef.RigthCoef(NC) = Coef.RigthCoef(NC) - flow.CourantNr End If MsgBox "Advection Type not defined:" & ctrl.AdvType End Sub


Download ppt "Evolution from VBA V1 to V2 (Numerics)"

Similar presentations


Ads by Google