Skip to content

Discrepancy in negation of a > statement #1670

@jlk9

Description

@jlk9

Running this script produces an error in the numerical values between Oceananigans models with and without reactant. This seems to be due to an error in how negations of > and >= operators are handled. If you look at lines 290 - 307:

    active_nodes = (!(grid.underlying_grid.z.cᵃᵃᶜ[k] ≤ grid.immersed_boundary.bottom_height[i, j-1, 1]) # NEGATING THIS ELIMINATES ERROR, NEED TO INVESTIGATE
                  & !(grid.underlying_grid.z.cᵃᵃᶜ[k] ≤ grid.immersed_boundary.bottom_height[i-1, j-1, 1])
                  & !(grid.underlying_grid.z.cᵃᵃᶜ[k] ≤ grid.immersed_boundary.bottom_height[i+1, j-1, 1])
                  & (j > 1)
                  & (j < (grid.Ny+2))
                  & (k > 0)
                  & (k < grid.Nz+1))
    
    #=
    # Works:
    active_nodes = ((grid.underlying_grid.z.cᵃᵃᶜ[k] > grid.immersed_boundary.bottom_height[i, j-1, 1])
                  & (grid.underlying_grid.z.cᵃᵃᶜ[k] > grid.immersed_boundary.bottom_height[i-1, j-1, 1])
                  & (grid.underlying_grid.z.cᵃᵃᶜ[k] > grid.immersed_boundary.bottom_height[i+1, j-1, 1])
                  & (j > 1)
                  & (j < (grid.Ny+2))
                  & (k > 0)
                  & (k < grid.Nz+1))
    =#

Logically these blocks should be equivalent (!(a ≤ b) == a > b, but they produce different values for the Reactant model.

@wsmoses

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions