Welcome, Guest
Username: Password: Remember me

TOPIC: Modifying Model.CrossSection.* variables through the Python API

Modifying Model.CrossSection.* variables through the Python API 4 years 4 months ago #36365

  • fviry
  • fviry's Avatar
Hi,

I am trying to modify the bathymetric profiles of my geometry through the Python API, using the telapy.api.masc.Mascaret class.

I am modifying the variable "Model.CrossSection.Y".

I tried to use the "set" method, but it throws the following error:
Variable Model.CrossSection.Y is readonly

This error is thrown by the "set" method itself, and I bypassed the problem by using the "set_double" method instead.

By looking at the Fortran sources of the Mascaret API, I noticed that some variables (e.g. "Model.CrossSection.*") are supposed to be "locked" by default, but is there a way to "unlock" them? Why are there "locked"?

I also noticed that the modification of "Model.CrossSection.*" variables is supposed to trigger the "planimétrage" at the beggining of the next computation.

Using "set_double" seems to work for me, but what is the right way to do what I am aiming to do (modifying the bathymetric profile between two runs)?

Thanks in advance
The administrator has disabled public write access.

Modifying Model.CrossSection.* variables through the Python API 4 years 4 months ago #36366

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi
Actually, when you run a mascaret model, the computation of hydraulic variables of the cross section is done only one before the computation.
If you change the cross section the parameters should be computed again which is not planned in Mascaret. This explain the lock.

Try to look in the courlis module as in this case, the bottom evolution generate a computation of the cross section parameters at each time step...

Regards
Christophe
The administrator has disabled public write access.

Modifying Model.CrossSection.* variables through the Python API 4 years 4 months ago #36372

  • fviry
  • fviry's Avatar
Hi,

Thanks for your answer.

To specify more precisely what I am doing: I am not trying to model sediment transport, but to perform some kind of sensitivity analysis of the hydraulic variables to geometric model parameters.
During one run (multiple time steps), my geometry is fixed.
But I am looking for a way to perform multiple runs with different values of the geometric variables.

If I well understood what you mean, those geometric variables are not expected to be modified: they are set only once when the model is imported, and the code is not expected to do anything when these variables are modified, explaining the "lock" mechanism.

It seems to be in contradiction with the code in
sources/mascaret/API/f90/set_valeur_mascaret.f90
at lines 67-68, there is the following comment about the modification of "Model.CrossSection.*" variables:
! On conserve l'indication que la geometrie a ete modifiee
! dans ce cas on pourra lancer le planimetrage avant le calcul.
that I understand as: when "Model.CrossSection.*" variables are modified, the numerical model parameters are recomputed as a preprocessing step at the next call of the "compute" method of the telapy.api.masc.Mascaret class.

I don't understand what does the code exactly.

Regards
The administrator has disabled public write access.
Moderators: JFourdrinoy

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.