Skip to content

Commit

Permalink
Améliorations conversions g1.2/g1.3 et couverture TU (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucduron authored Sep 27, 2024
1 parent 6fb4459 commit 6a4f588
Show file tree
Hide file tree
Showing 84 changed files with 4,478 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Journal des modifications
=========================

## [X.X] en cours
- Prise en compte du déplacement de Pm_TolStQ du CCM vers le OPTI pour les initialisations de type Saint-Venant (g1.3)
- Amélioration performances lecture binaire en utilisant `np.frombuffer` (au lieu de struct)
- Correction plantage lecture RCAL si aucun résultat aux branches

Expand Down
2 changes: 1 addition & 1 deletion crue10/data/1.2/templates/dcsp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@
{%- else %}
<DonCalcSansPrtCasiers/>
{%- endif %}
</DCSP>
</DCSP>
2 changes: 1 addition & 1 deletion crue10/data/1.2/templates/dptg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@
{%- else %}
<DonPrtGeoBranches/>
{%- endif %}
</DPTG>
</DPTG>
2 changes: 1 addition & 1 deletion crue10/data/1.2/templates/dpti.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
{%- else %}
<DonPrtCIniBranches/>
{%- endif %}
</DPTI>
</DPTI>
2 changes: 1 addition & 1 deletion crue10/data/1.2/templates/drso.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@
{%- else %}
<Branches/>
{%- endif %}
</DRSO>
</DRSO>
2 changes: 1 addition & 1 deletion crue10/data/1.2/templates/etu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@
</Scenario>
{%- endfor %}
</Scenarios>
</ETU>
</ETU>
2 changes: 1 addition & 1 deletion crue10/data/1.3/templates/dptg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@
{%- else %}
<DonPrtGeoBranches/>
{%- endif %}
</DPTG>
</DPTG>
2 changes: 1 addition & 1 deletion crue10/data/1.3/templates/dpti.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@
{%- else %}
<DonPrtCIniBranches/>
{%- endif %}
</DPTI>
</DPTI>
2 changes: 1 addition & 1 deletion crue10/data/1.3/templates/drso.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@
{%- else %}
<Branches/>
{%- endif %}
</DRSO>
</DRSO>
2 changes: 1 addition & 1 deletion crue10/data/1.3/templates/etu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@
</Scenario>
{%- endfor %}
</Scenarios>
</ETU>
</ETU>
26 changes: 25 additions & 1 deletion crue10/modele.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from crue10.emh.branche import Branche, BrancheOrifice, BrancheBarrageFilEau, BrancheBarrageGenerique
from crue10.emh.section import SectionIdem, SectionProfil, LimiteGeom, LitNumerote
from crue10.utils import check_isinstance, check_preffix, DATA_FOLDER_ABSPATH, duration_iso8601_to_seconds, \
duration_seconds_to_iso8601, get_xml_root_from_file, logger, PREFIX, write_default_xml_file, write_xml_from_tree
duration_seconds_to_iso8601, float2str, get_xml_root_from_file, logger, \
PREFIX, write_default_xml_file, write_xml_from_tree
from crue10.utils.crueconfigmetier import DEFAULT_Pm_TolStQ
from crue10.utils.graph_1d_model import *
from crue10.sous_modele import SousModele

Expand Down Expand Up @@ -755,13 +757,35 @@ def changer_version_grammaire(self, version_grammaire, shallow=False):
:type shallow: bool
"""
if version_grammaire == '1.3': # HARDCODED to support g1.2
interpol_st_venant = self.xml_trees['opti'].find(PREFIX + 'MethodeInterpol') \
.find(PREFIX + 'InterpolSaintVenant')
if interpol_st_venant is not None:
# Fix indentation (add 2 whitespaces)
elt_Pm_TolNdZ = interpol_st_venant.find(PREFIX + 'Pm_TolNdZ')
elt_Pm_TolNdZ.tail += ' '
# Parameter `Pm_TolStQ` is added (it was in CCM before)
elt_Pm_TolStQ = etree.SubElement(interpol_st_venant, PREFIX + 'Pm_TolStQ')
elt_Pm_TolStQ.text = float2str(DEFAULT_Pm_TolStQ)
elt_Pm_TolStQ.tail = '\n '

if 'dreg' not in self.xml_trees:
# Add dreg in self.xml_trees if missing (because is from grammar v1.2)
xml_path = os.path.join(DATA_FOLDER_ABSPATH, version_grammaire, 'fichiers_vierges', 'default.dreg.xml')
root = get_xml_root_from_file(xml_path)
self.xml_trees['dreg'] = root
self.files['dreg'] = os.path.join(os.path.dirname(self.files['optr']), self.id[3:] + '.dreg.xml')

elif version_grammaire == '1.2': # HARDCODED to support g1.2
interpol_st_venant = self.xml_trees['opti'].find(PREFIX + 'MethodeInterpol') \
.find(PREFIX + 'InterpolSaintVenant')
if interpol_st_venant is not None:
# Fix indentation (remove 2 whitespaces)
elt_Pm_TolNdZ = interpol_st_venant.find(PREFIX + 'Pm_TolNdZ')
if elt_Pm_TolNdZ.tail.endswith(' '):
elt_Pm_TolNdZ.tail = elt_Pm_TolNdZ.tail[:-2]
# Parameter `Pm_TolStQ` removed as it was in CCM before
interpol_st_venant.remove(interpol_st_venant.find(PREFIX + 'Pm_TolStQ'))

if not shallow:
for sous_modele in self.liste_sous_modeles:
sous_modele.changer_version_grammaire(version_grammaire)
Expand Down
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
102 changes: 102 additions & 0 deletions crue10/tests/data/in/1.2/Etu3-6_grammaire/Etu3-6.etu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<ETU xmlns="http://www.fudaa.fr/xsd/crue" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fudaa.fr/xsd/crue http://www.fudaa.fr/xsd/crue/etu-1.2.xsd">
<Commentaire>Etu3-6 : étude basée sur Etu3-0</Commentaire>
<AuteurCreation>BALAYN_P</AuteurCreation>
<DateCreation>2012-05-30T12:00:00.000</DateCreation>
<AuteurDerniereModif>DURON</AuteurDerniereModif>
<DateDerniereModif>2024-09-27T15:17:57.547</DateDerniereModif>
<ScenarioCourant NomRef="Sc_M3-6_c10"/>
<Repertoires>
<Repertoire Nom="CONFIG">
<path>CONFIG</path>
</Repertoire>
<Repertoire Nom="FICHETUDES">
<path>.</path>
</Repertoire>
<Repertoire Nom="RAPPORTS">
<path>RAPPORTS</path>
</Repertoire>
<Repertoire Nom="RUNS">
<path>RUNS</path>
</Repertoire>
</Repertoires>
<FichEtudes>
<FichEtude Nom="M3-6_c10.dclm.xml" Chemin=".\" Type="DCLM"/>
<FichEtude Nom="M3-6_c10.dcsp.xml" Chemin=".\" Type="DCSP"/>
<FichEtude Nom="M3-6_c10.dfrt.xml" Chemin=".\" Type="DFRT"/>
<FichEtude Nom="M3-6_c10.dlhy.xml" Chemin=".\" Type="DLHY"/>
<FichEtude Nom="M3-6_c10.dptg.xml" Chemin=".\" Type="DPTG"/>
<FichEtude Nom="M3-6_c10.dpti.xml" Chemin=".\" Type="DPTI"/>
<FichEtude Nom="M3-6_c10.drso.xml" Chemin=".\" Type="DRSO"/>
<FichEtude Nom="M3-6_c10.ocal.xml" Chemin=".\" Type="OCAL"/>
<FichEtude Nom="M3-6_c10.optg.xml" Chemin=".\" Type="OPTG"/>
<FichEtude Nom="M3-6_c10.opti.xml" Chemin=".\" Type="OPTI"/>
<FichEtude Nom="M3-6_c10.optr.xml" Chemin=".\" Type="OPTR"/>
<FichEtude Nom="M3-6_c10.ores.xml" Chemin=".\" Type="ORES"/>
<FichEtude Nom="M3-6_c10.pcal.xml" Chemin=".\" Type="PCAL"/>
<FichEtude Nom="M3-6_c10.pnum.xml" Chemin=".\" Type="PNUM"/>
</FichEtudes>
<SousModeles>
<SousModele Nom="Sm_M3-6_c10">
<Type>Crue10</Type>
<IsActive>true</IsActive>
<Commentaire>Sc_M3-6_c9 converti en CRUE10

Régimes permanents seuls. CLimM : Qapp, Zimp, Ouv --&gt; incompatible avec c10m9</Commentaire>
<AuteurCreation>gressier</AuteurCreation>
<DateCreation>2017-06-23T09:06:14.245</DateCreation>
<AuteurDerniereModif>DURON</AuteurDerniereModif>
<DateDerniereModif>2024-09-27T15:17:57.542</DateDerniereModif>
<SousModele-FichEtudes>
<DRSO NomRef="M3-6_c10.drso.xml"/>
<DCSP NomRef="M3-6_c10.dcsp.xml"/>
<DPTG NomRef="M3-6_c10.dptg.xml"/>
<DFRT NomRef="M3-6_c10.dfrt.xml"/>
</SousModele-FichEtudes>
</SousModele>
</SousModeles>
<Modeles>
<Modele Nom="Mo_M3-6_c10">
<Type>Crue10</Type>
<IsActive>true</IsActive>
<Commentaire>Sc_M3-6_c9 converti en CRUE10

Régimes permanents seuls. CLimM : Qapp, Zimp, Ouv --&gt; incompatible avec c10m9</Commentaire>
<AuteurCreation>gressier</AuteurCreation>
<DateCreation>2017-06-23T09:06:14.245</DateCreation>
<AuteurDerniereModif>DURON</AuteurDerniereModif>
<DateDerniereModif>2024-09-27T15:17:57.542</DateDerniereModif>
<Modele-FichEtudes>
<OPTR NomRef="M3-6_c10.optr.xml"/>
<OPTG NomRef="M3-6_c10.optg.xml"/>
<OPTI NomRef="M3-6_c10.opti.xml"/>
<PNUM NomRef="M3-6_c10.pnum.xml"/>
<DPTI NomRef="M3-6_c10.dpti.xml"/>
</Modele-FichEtudes>
<Modele-SousModeles>
<Modele-SousModele NomRef="Sm_M3-6_c10"/>
</Modele-SousModeles>
</Modele>
</Modeles>
<Scenarios>
<Scenario Nom="Sc_M3-6_c10">
<Type>Crue10</Type>
<IsActive>true</IsActive>
<Commentaire>Régimes permanents seuls. CLimM : Qapp, Zimp, Ouv --&gt; incompatible avec c10m9</Commentaire>
<AuteurCreation>gressier</AuteurCreation>
<DateCreation>2017-06-23T09:06:14.245</DateCreation>
<AuteurDerniereModif>DURON</AuteurDerniereModif>
<DateDerniereModif>2024-09-27T15:17:57.542</DateDerniereModif>
<Scenario-FichEtudes>
<OCAL NomRef="M3-6_c10.ocal.xml"/>
<ORES NomRef="M3-6_c10.ores.xml"/>
<PCAL NomRef="M3-6_c10.pcal.xml"/>
<DCLM NomRef="M3-6_c10.dclm.xml"/>
<DLHY NomRef="M3-6_c10.dlhy.xml"/>
</Scenario-FichEtudes>
<Scenario-Modeles>
<Scenario-Modele NomRef="Mo_M3-6_c10"/>
</Scenario-Modeles>
</Scenario>
</Scenarios>
</ETU>
40 changes: 40 additions & 0 deletions crue10/tests/data/in/1.2/Etu3-6_grammaire/M3-6_c10.dclm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<DCLM xmlns="http://www.fudaa.fr/xsd/crue" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fudaa.fr/xsd/crue http://www.fudaa.fr/xsd/crue/dclm-1.2.xsd">
<Commentaire>CrueX - Structuration des données

Modèle de test utilisant les éléments de modélisation hydraulique les plus courants

PBa Mai2012 sur la base de M3-0</Commentaire>
<CalcPseudoPerm Nom="Cc_P01">
<Commentaire>Calcul pseudo-permanent 1</Commentaire>
<CalcPseudoPermNoeudQapp NomRef="Nd_N1">
<IsActive>true</IsActive>
<Qapp>100.0</Qapp>
</CalcPseudoPermNoeudQapp>
<CalcPseudoPermNoeudNiveauContinuZimp NomRef="Nd_N5">
<IsActive>true</IsActive>
<Zimp>2.0</Zimp>
</CalcPseudoPermNoeudNiveauContinuZimp>
<CalcPseudoPermBrancheOrificeManoeuvre NomRef="Br_B8">
<IsActive>true</IsActive>
<SensOuv>OuvVersHaut</SensOuv>
<Ouv>100.0</Ouv>
</CalcPseudoPermBrancheOrificeManoeuvre>
</CalcPseudoPerm>
<CalcPseudoPerm Nom="Cc_P02">
<Commentaire>Calcul pseudo-permanent 2</Commentaire>
<CalcPseudoPermNoeudQapp NomRef="Nd_N1">
<IsActive>true</IsActive>
<Qapp>100.0</Qapp>
</CalcPseudoPermNoeudQapp>
<CalcPseudoPermNoeudNiveauContinuZimp NomRef="Nd_N5">
<IsActive>true</IsActive>
<Zimp>1.5</Zimp>
</CalcPseudoPermNoeudNiveauContinuZimp>
<CalcPseudoPermBrancheOrificeManoeuvre NomRef="Br_B8">
<IsActive>true</IsActive>
<SensOuv>OuvVersHaut</SensOuv>
<Ouv>90.0</Ouv>
</CalcPseudoPermBrancheOrificeManoeuvre>
</CalcPseudoPerm>
</DCLM>
79 changes: 79 additions & 0 deletions crue10/tests/data/in/1.2/Etu3-6_grammaire/M3-6_c10.dcsp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<DCSP xmlns="http://www.fudaa.fr/xsd/crue" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fudaa.fr/xsd/crue http://www.fudaa.fr/xsd/crue/dcsp-1.2.xsd">
<Commentaire></Commentaire>
<DonCalcSansPrtBranches>
<DonCalcSansPrtBrancheSaintVenant NomRef="Br_B1">
<CoefBeta>1.0</CoefBeta>
<CoefRuisQdm>0.0</CoefRuisQdm>
<CoefRuis>0.0</CoefRuis>
</DonCalcSansPrtBrancheSaintVenant>
<DonCalcSansPrtBrancheSaintVenant NomRef="Br_B2">
<CoefBeta>1.0</CoefBeta>
<CoefRuisQdm>0.0</CoefRuisQdm>
<CoefRuis>0.0</CoefRuis>
</DonCalcSansPrtBrancheSaintVenant>
<DonCalcSansPrtBrancheSeuilTransversal NomRef="Br_B3">
<FormulePdc>Borda</FormulePdc>
<ElemSeuilAvecPdc>
<Largeur>20.0</Largeur>
<Zseuil>0.6</Zseuil>
<CoefD>0.9</CoefD>
<CoefPdc>1.0</CoefPdc>
</ElemSeuilAvecPdc>
<ElemSeuilAvecPdc>
<Largeur>8.0</Largeur>
<Zseuil>2.2</Zseuil>
<CoefD>0.9</CoefD>
<CoefPdc>1.0</CoefPdc>
</ElemSeuilAvecPdc>
</DonCalcSansPrtBrancheSeuilTransversal>
<DonCalcSansPrtBrancheSaintVenant NomRef="Br_B4">
<CoefBeta>1.0</CoefBeta>
<CoefRuisQdm>0.0</CoefRuisQdm>
<CoefRuis>0.0</CoefRuis>
</DonCalcSansPrtBrancheSaintVenant>
<DonCalcSansPrtBrancheSeuilLateral NomRef="Br_B5">
<FormulePdc>Borda</FormulePdc>
<ElemSeuilAvecPdc>
<Largeur>100.0</Largeur>
<Zseuil>3.78</Zseuil>
<CoefD>0.9</CoefD>
<CoefPdc>1.0</CoefPdc>
</ElemSeuilAvecPdc>
<ElemSeuilAvecPdc>
<Largeur>100.0</Largeur>
<Zseuil>3.82</Zseuil>
<CoefD>0.9</CoefD>
<CoefPdc>1.0</CoefPdc>
</ElemSeuilAvecPdc>
</DonCalcSansPrtBrancheSeuilLateral>
<DonCalcSansPrtBrancheBarrageFilEau NomRef="Br_B8">
<QLimInf>-1.0E30</QLimInf>
<QLimSup>1.0E30</QLimSup>
<ElemSeuil>
<Largeur>10.0</Largeur>
<Zseuil>1.234</Zseuil>
<CoefD>0.6</CoefD>
</ElemSeuil>
<ElemSeuil>
<Largeur>12.0</Largeur>
<Zseuil>5.678</Zseuil>
<CoefD>0.3</CoefD>
</ElemSeuil>
<RegimeDenoye Nom="LoiQpilZam_B8" Type="LoiQpilZam">
<Commentaire></Commentaire>
<EvolutionFF>
<PointFF>0.0 -15.0</PointFF>
</EvolutionFF>
</RegimeDenoye>
</DonCalcSansPrtBrancheBarrageFilEau>
</DonCalcSansPrtBranches>
<DonCalcSansPrtCasiers>
<DonCalcSansPrtCasierProfil NomRef="Ca_N7">
<CoefRuis>0.0</CoefRuis>
</DonCalcSansPrtCasierProfil>
<DonCalcSansPrtCasierProfil NomRef="Ca_N6">
<CoefRuis>0.0</CoefRuis>
</DonCalcSansPrtCasierProfil>
</DonCalcSansPrtCasiers>
</DCSP>
Loading

0 comments on commit 6a4f588

Please sign in to comment.