Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model constructor is slightly mangled #647

Closed
glwagner opened this issue Feb 27, 2020 · 1 comment · Fixed by #662
Closed

Model constructor is slightly mangled #647

glwagner opened this issue Feb 27, 2020 · 1 comment · Fixed by #662
Assignees
Labels
bug 🐞 Even a perfect program still has bugs cleanup 🧹 Paying off technical debt models 🧫

Comments

@glwagner
Copy link
Member

The signature of the model constructor is

function IncompressibleModel(;
                   grid,
           architecture = CPU(),
             float_type = Float64,
                tracers = (:T, :S),
                closure = ConstantIsotropicDiffusivity(float_type, ν=ν₀, κ=κ₀),
                  clock = Clock{float_type}(0, 0), 
               buoyancy = SeawaterBuoyancy(float_type),
               coriolis = nothing,
          surface_waves = nothing,
                forcing = ModelForcing(),
    boundary_conditions = (u=UVelocityBoundaryConditions(grid),
                           v=VVelocityBoundaryConditions(grid),
                           w=WVelocityBoundaryConditions(grid)),
             parameters = nothing,
             velocities = VelocityFields(architecture, grid, boundary_conditions),
          tracer_fields = TracerFields(architecture, grid, tracernames(tracers), boundary_conditions),
              pressures = PressureFields(architecture, grid, boundary_conditions),
          diffusivities = DiffusivityFields(architecture, grid, tracernames(tracers), boundary_conditions, closure),
     timestepper_method = :AdamsBashforth,
            timestepper = TimeStepper(timestepper_method, float_type, architecture, grid, tracernames(tracers)),
        pressure_solver = PressureSolver(architecture, grid, PressureBoundaryConditions(grid))
    )   

Issues:

  1. tracers is apparently expected only to be a tuple of symbols. Nevertheless, the function tracernames is called on this argument --- whose only purpose is to return tracer names when its argument may either be a tuple of symbols, or a tuple of fields.

  2. The arguments (tracers, tracer_fields) and (timestepper_method, timestepper) are redundant.

  3. Worse, tracer_fields can be set to something inconsistent with tracers, and therefore diffusivities and timestepper.

It's probably best if we assign only one keyword argument to each "concept", for the sake of simplicity and interpretability. A little bit of cleaning / interpretation to arguments (eg, if an argument may either be a tuple of symbols corresponding to tracer names, or a tuple of tracer fields) is ok, in my opinion, because it could make the code less confusing and easier to use.

@glwagner glwagner self-assigned this Feb 28, 2020
@glwagner glwagner added bug 🐞 Even a perfect program still has bugs cleanup 🧹 Paying off technical debt labels Feb 28, 2020
@ali-ramadhan
Copy link
Member

I guess part of the confusion is that some kwargs are for users while others were introduced for checkpointer usage. I agree that timestepper_method and timestepper are redundant. We should be able to just do something like time_stepper = AdamsBashforth2() for something.

Or go with your suggestion on Slack of having the choice of either passing a Symbol for a full struct. Users might usually pass tracers = (:a, :b) but checkpointer might pass tracers = TracerFields(...).

It's probably best if we assign only one keyword argument to each "concept", for the sake of simplicity and interpretability.

I'm totally on board with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Even a perfect program still has bugs cleanup 🧹 Paying off technical debt models 🧫
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants