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

SIMVALS - Get a list of them and find out what they mean #61

Open
pya opened this issue Nov 24, 2024 · 0 comments
Open

SIMVALS - Get a list of them and find out what they mean #61

pya opened this issue Nov 24, 2024 · 0 comments

Comments

@pya
Copy link

pya commented Nov 24, 2024

Context

I am trying to understand the example for using modflowapi presented by @jdhughes-usgs during the MODFLW6 training at DSD24, November 22, 2024 .
The example Notebook has these lines of code:

tag = ml.mf6.get_var_address("SIMVALS", "MODEL", "RIVER")
self.sim_flux = ml.mf6.get_value_ptr(tag)

in the method callback in the class FluxMonitor. I assume the name "RIVER" in above code comes from the line RIV6 model.riv river in the file temp/model.nam:

BEGIN options
  PRINT_INPUT
  SAVE_FLOWS
END options

BEGIN packages
  DIS6  model.dis  dis
  NPF6  model.npf  npf
  IC6  model.ic  ic
  RIV6  model.riv  river
  CHD6  model.chd  chd_0
  OC6  model.oc  oc
END packages

that is generated by flopy.

How do get a list of all SIMVALS?

I would like to know what SIMVALS such as RIVER are available for the use in modlfowapi. Can I get list of all names that I could use instead of MYVARNAME in the this code (extracted from above code):

tag = ml.mf6.get_var_address("SIMVALS", "MODEL", "MYVARNAME")

How can I do this? Ideally, I would like to get this list dynamically with Python during initialization, i.e. in the block below callback_step == Callbacks.initialize.

What do the variables stand for?

I tried to get the constant head data during run time. From the line CHD6 model.chd chd_0 in the file temp/model.nam I concluded that the name I can use to get a pointer to CHD values is CHD_0. Therefore, I modified the code in callback:

        if callback_step == Callbacks.initialize:
            ml = sim.get_model()
            flux_tag = ml.mf6.get_var_address("SIMVALS", "MODEL", "RIVER")
            self.sim_flux = ml.mf6.get_value_ptr(flux_tag)

            chd_tag = ml.mf6.get_var_address("SIMVALS", "MODEL", "CHD_0")
            self.sim_chd = ml.mf6.get_value_ptr(chd_tag)
            
            self.initialize_plot()

        if callback_step == Callbacks.iteration_start:
            riv = sim.model.river
            spd = sim.model.river.stress_period_data.values
            if sim.model.X[0, 0, 0] > self.h_mean:
                cond = condref
            else:
                cond = condref * 0.10
            spd[0] = ((0, 0, 0), h_mean, cond, 319.0)
            sim.model.river.stress_period_data.values = spd        

        if callback_step == Callbacks.timestep_end:
            ml = sim.get_model()
            self.flux.append(float(self.sim_flux.sum()))
            self.chd.append(float(self.sim_chd[0]))
            self.update_plot(ml)

The import lines are creating self.sim_chd:

chd_tag = ml.mf6.get_var_address("SIMVALS", "MODEL", "CHD_0")
self.sim_chd = ml.mf6.get_value_ptr(chd_tag)

in the block callback_step == Callbacks.initialize and appending its values at each time step to self.chd:

 self.chd.append(float(self.sim_chd[0]))

in the block callback_step == Callbacks.timestep_end.

The result are the fluxes with opposite sign, i.e. self.chd == -self.flux:

>>> np.allclose(np.array(fmon.chd),  - np.array(fmon.flux))
True

So SIMVALS are always the flux, correct? fmon.flux contains them at all river locations from the "river perspective" and fmon.chd contains them at all CHD cells from from the "chd perspective". Due to the two-element model, one cell containing the river and other cell containing chd, both fluxes have the sam absolute values with opposite signs. Is this correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant