TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Potentiel_Multicouche.cpp
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Potentiel_Multicouche.h>
17#include <Fermeture_Thermo_base.h>
18#include <math.h>
19
20Implemente_instanciable(Potentiel_Multicouche, "Multicouche", Potentiel_Chimique_base);
21
23{
24 os << que_suis_je() << finl;
25 os << "nb_couches " << nb_parametres_d_ordre_ << finl;
26 os << "Omega_a " << omega_a_ << finl;
27 os << "Omega_b " << omega_b_ << finl;
28 os << "Omega_c " << omega_c_ << finl;
30}
31
33{
34 Cerr << "Reading parameters of potential " << que_suis_je() << " ..." << finl;
35
36 Param param(que_suis_je());
37
38 param.ajouter("nb_couches", &nb_parametres_d_ordre_, Param::REQUIRED);
39 param.ajouter("Omega_a", &omega_a_, Param::REQUIRED);
40 param.ajouter("Omega_b", &omega_b_, Param::REQUIRED);
41 param.ajouter("Omega_c", &omega_c_, Param::REQUIRED);
42
43 param.lire_avec_accolades_depuis(is);
44
45 return is;
46}
47
48DoubleTab Potentiel_Multicouche::dWdc(const DoubleTab& c)
49{
50 dWdc_ = c; // Copie de structure
51 dWdc_ = 0;
52 const double tol=1.e-20; // Tolérance sur la sortie des bornes
53
54 for (int i = 0; i < c.dimension(0); i++) // Dimension du domaine
55 for (int j = 0; j < c.line_size(); j++) // Nombre de couches
56 {
57 if ((c(i,j) > 1.-tol) || (c(i,j) < tol)) // Si c >= 1 ou c <= 0, on a un problème (logarithme non défini)
58 {
59 // dWdc_(i,j) = omega_a_*(1. - 2.*c(i,j));
60 Cerr << "[Potentiel_Multicouche] :: Warning : c >= 1 or c <= 0." << finl;
61 }
62 dWdc_(i, j) = log(std::max(c(i,j),tol)/(1.-std::min(c(i,j),1.-tol))) + omega_a_*(1. - 2.*c(i,j)); // + mu_eq; // On peut rajouter le potentiel de référence pour shifter le potentiel
63 //dWdc_(i, j) = log(c(i,j)/(1.-c(i,j))) + omega_a_*(1. - 2.*c(i,j)); // + mu_eq; // On peut rajouter le potentiel de référence pour shifter le potentiel
64
65
66 // Si on a plus d'une couche --> Rajout de l'interaction aux premiers voisins
68 {
69 int mod_j_plus_1 = (j+1) % nb_parametres_d_ordre_;
70 int mod_j_moins_1 = (j+nb_parametres_d_ordre_-1) % nb_parametres_d_ordre_;
71
72 dWdc_(i, j) += omega_b_*(c(i,mod_j_plus_1) + c(i,mod_j_moins_1));
73
74 // Si on a plus de 2 couches --> Rajout de l'interaction aux seconds voisins
76 {
77 int mod_j_plus_2 = (j+2) % nb_parametres_d_ordre_;
78 int mod_j_moins_2 = (j+nb_parametres_d_ordre_-2) % nb_parametres_d_ordre_;
79
80 // Termes d'écrantages des premiers voisins
81 dWdc_(i, j) += omega_c_*(c(i,mod_j_plus_2)*(1. - c(i,mod_j_plus_1)) + c(i,mod_j_moins_2)*(1. - c(i,mod_j_moins_1))
82 - c(i,mod_j_plus_1)*c(i,mod_j_moins_1));
83 }
84 }
85 }
86
87 return dWdc_;
88}
89
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
@ REQUIRED
Definition Param.h:115
DoubleTab dWdc(const DoubleTab &) override
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67