431
432 class(EvtType) :: this
433
434 integer(I4B) :: i, iseg, node
435 integer(I4B) :: idxdepth, idxrate
436 real(DP) :: c, d, h, s, x
437 real(DP) :: petm0
438 real(DP) :: petm1, petm2, pxdp1, pxdp2, thcof, trhs
439
440
441 if (this%nbound == 0) return
442
443
444 do i = 1, this%nbound
445
446
447 if (this%fixed_cell) then
448 node = this%nodelist(i)
449 else
450 node = this%nodesontop(i)
451 end if
452
453
454 if (node <= 0) then
455 this%hcof(i) = dzero
456 this%rhs(i) = dzero
457 cycle
458 end if
459
460
461 if (.not. this%fixed_cell) then
462 if (this%ibound(node) == 0) &
463 call this%dis%highest_active(node, this%ibound)
464 this%nodelist(i) = node
465 end if
466
467
468 this%rhs(i) = dzero
469 this%hcof(i) = dzero
470
471
472 if (this%ibound(node) > 0 .and. this%ibound(node) /= iwetlake) then
473
474 if (this%iauxmultcol > 0) then
475 c = this%rate(i) * this%dis%get_area(node) * &
476 this%auxvar(this%iauxmultcol, i)
477 else
478 c = this%rate(i) * this%dis%get_area(node)
479 end if
480 s = this%surface(i)
481 h = this%xnew(node)
482 if (this%surfratespecified) then
483 petm0 = this%petm0(i)
484 end if
485
486
487 if (h >= s) then
488 if (this%surfratespecified) then
489
490 this%rhs(i) = this%rhs(i) + petm0 * c
491 else
492
493 this%rhs(i) = this%rhs(i) + c
494 end if
495 else
496
497 d = s - h
498 x = this%depth(i)
499 if (d < x) then
500
501 if (this%nseg > 1) then
502
503
504
505
506
507
508
509
510
511
512
513 pxdp1 = dzero
514 if (this%surfratespecified) then
515 petm1 = petm0
516 else
517 petm1 = done
518 end if
519
520
521 idxdepth = 0
522 idxrate = 0
523
524
525 segloop: do iseg = 1, this%nseg
526
527
528 if (iseg < this%nseg) then
529
530 idxdepth = idxdepth + 1
531 idxrate = idxrate + 1
532
533 pxdp2 = this%pxdp(idxdepth, i)
534 petm2 = this%petm(idxrate, i)
535 else
536 pxdp2 = done
537 petm2 = dzero
538 end if
539 if (d <= pxdp2 * x) then
540
541 exit segloop
542 end if
543
544
545 pxdp1 = pxdp2
546 petm1 = petm2
547 end do segloop
548
549
550 thcof = -(petm1 - petm2) * c / ((pxdp2 - pxdp1) * x)
551 trhs = thcof * (s - pxdp1 * x) + petm1 * c
552 else
553
554
555 trhs = c - c * s / x
556 thcof = -c / x
557 end if
558 this%rhs(i) = this%rhs(i) + trhs
559 this%hcof(i) = this%hcof(i) + thcof
560 end if
561 end if
562 end if
563
564 end do