Welcome, Guest
Username: Password: Remember me

TOPIC: How to include a PRIVE variable in TelApy dynamic simulation

How to include a PRIVE variable in TelApy dynamic simulation 2 years 6 months ago #40339

Dear All,

I have been trying to develop a simulation to couple Python code with Telemac2d, similar to this article. In my code, the objective function needs different variables that need to be computed using user subroutines, such as velocity gradients or strain rate. I have computed my variables using fortran subroutines:
  • user_nomvar_telemac2d.f
  • user_preres_telemac2d.f

As stated in the user manual, I have four private variables which can be used and exported in the results.slf

I have tried to access the variable through TelApy: telapy.api.t2d.Telemac.py

Nevertheless, there is no documentation to retrieve these user variables. The TelApy user manual, provides step to add new variables to API Fortran by modifying the file in the source folder declarations_telemac2d.f and then add it to api_instance_t2d.f.

Is there a way to access them without modifying the source code? I checked the declarations_telemac2d.f, file and it seems that the variables 'PRIVE' are declared in:
2260       DOUBLE PRECISION,POINTER :: PRIVE1(:),PRIVE2(:)
2261       DOUBLE PRECISION,POINTER :: PRIVE3(:),PRIVE4(:)

Are this the variables used in user_nomvar_telemac2d.f?
Is it possible to access via API Fortran this variables without modifying the source code?

I have started to use telemac a couple of months ago and I am still a beginner.

I really appreciate any help

Kind regards,

Marcelo
The administrator has disabled public write access.

How to include a PRIVE variable in TelApy dynamic simulation 2 years 6 months ago #40343

  • pham
  • pham's Avatar
  • OFFLINE
  • Administrator
  • Posts: 1559
  • Thank you received: 602
Hello Marcelo,

If a variable is not accessible by TelApy yet, the only way to get it is to follow the procedure described in section 4.1.2 of the TelApy user manual and change the source code. As written, there is a script which does almost everything.

If you want to use tuned TELEMAC, you have to learn Fortran, it is easier to learn than using TELEMAC correctly.

Hope this helps,

Chi-Tuan
The administrator has disabled public write access.

How to include a PRIVE variable in TelApy dynamic simulation 2 years 6 months ago #40359

Dear chi-tuan,

Thank you very much, I have successfuly added to API the variables I needed to compute my user defined subroutine in fortran user. Unfortunatelly, the block prive is added to API, but I cannot access it with any command line, including my_case.get('MODEL.PRIVE',i,j,k) or my_case.get_array('MODEL.PRIVE').

I have a doubt though,

When I try to access the turbulent kinetic energy, TKE, 'MODEL.AK' with the command:
TKE = my_case.get_array('MODEL.AK')

The result is:
TKE
array([0, 0, 0, 0, 0,...., 0, 0, 0])

However when I use:
for i in range(my_case.get('NPOINT'))
           TKE[i]=my_case.get('MODEL.AK',i)

The result is:
TKE
array([6.04448251e-05, 1.32085143e-09, 1.42959160e-11, ...,
       1.45186437e-04, 1.03965960e-03, 8.92243290e-04])

I do not understand why this happends, if you can give me some insights I will save a lot of computational time and be able to use 'mpi4py' to optimize my code.

I really appreciate your help,

Kind regards,

Marcelo
The administrator has disabled public write access.

How to include a PRIVE variable in TelApy dynamic simulation 2 years 5 months ago #40457

  • pham
  • pham's Avatar
  • OFFLINE
  • Administrator
  • Posts: 1559
  • Thank you received: 602
Hello Marcelo,

Sorry for the delay, I was busy the last weeks.

A colleague of mine who better knows about TelApy told me that the reason why you got this is because MODEL.AK is not defined in GET_DOUBLE_ARRAY_T2D_D nor SET_DOUBLE_ARRAY_T2D_D in api_handle_var_t2d.f (it should be corrected for next release).

Hope this helps,

Chi-Tuan
The administrator has disabled public write access.

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