142 #include "eos_bifluid.h" 144 #include "utilitaires.h" 155 name(
"EoS bi-fluid"), m_1(1), m_2(1)
161 name(name_i), m_1(mass1), m_2(mass2)
167 name(eos_i.name), m_1(eos_i.m_1), m_2(eos_i.m_2)
174 char dummy [MAX_EOSNAME];
175 if (fread(dummy,
sizeof(
char),MAX_EOSNAME, fich) == 0)
176 cerr <<
"Reading problem in " << __FILE__ << endl ;
189 char* char_name =
const_cast<char*
>(
"name");
190 char* char_m1 =
const_cast<char*
>(
"m_1") ;
191 char* char_m2 =
const_cast<char*
>(
"m_2") ;
202 cerr <<
"ERROR: Eos_bifluid(const char*): could not read either of \ 203 the variables 'name', 'm_1, or 'm_2' from file " << fname << endl;
218 fich.ignore(1000,
'\n') ;
220 fich >>
m_1 ; fich.ignore(1000,
'\n') ;
221 fich >>
m_2 ; fich.ignore(1000,
'\n') ;
252 assert(
name.size() < MAX_EOSNAME) ;
253 char dummy [MAX_EOSNAME];
256 fwrite_be(&ident,
sizeof(
int), 1, fich) ;
258 strncpy (dummy,
name.c_str(), MAX_EOSNAME);
259 dummy[MAX_EOSNAME-1] = 0;
260 if (fwrite(dummy,
sizeof(
char), MAX_EOSNAME, fich ) == 0)
261 cerr <<
"Writing problem in " << __FILE__ << endl ;
271 ost <<
" Mean particle 1 mass : " << eqetat.
get_m1() <<
" m_B" << endl ;
272 ost <<
" Mean particle 2 mass : " << eqetat.
get_m2() <<
" m_B" << endl ;
287 const Cmp& delta2,
Cmp& nbar1,
Cmp& nbar2,
289 int nzet,
int l_min)
const {
291 assert(ent1.
get_etat() != ETATNONDEF) ;
292 assert(ent2.
get_etat() != ETATNONDEF) ;
293 assert(delta2.
get_etat() != ETATNONDEF) ;
296 assert(mp == ent2.
get_mp()) ;
297 assert(mp == delta2.
get_mp()) ;
298 assert(mp == ener.
get_mp()) ;
312 const Mg3d* mg = mp->get_mg() ;
319 nbar1.
annule(0, l_min-1) ;
320 nbar2.
annule(0, l_min-1) ;
322 press.
annule(0, l_min-1) ;
325 if (l_min + nzet < nz) {
326 nbar1.
annule(l_min + nzet, nz - 1) ;
327 nbar2.
annule(l_min + nzet, nz - 1) ;
328 ener.
annule(l_min + nzet, nz - 1) ;
329 press.
annule(l_min + nzet, nz - 1) ;
332 int np0 = mp->get_mg()->get_np(0) ;
333 int nt0 = mp->get_mg()->get_nt(0) ;
334 for (
int l=l_min; l<l_min+nzet; l++) {
335 assert(mp->get_mg()->get_np(l) == np0) ;
336 assert(mp->get_mg()->get_nt(l) == nt0) ;
342 bool slow_rot_style =
false;
347 if (this_eos -> get_typeos() == 5)
349 slow_rot_style =
true;
350 cout <<
"DEBUG: using EOS-inversion slow-rot-style!! " << endl;
356 for (
int k=0; k<np0; k++) {
357 for (
int j=0; j<nt0; j++) {
359 bool inside1 = true ;
360 bool inside2 = true ;
361 for (
int l=l_min; l< l_min + nzet; l++) {
362 for (
int i=0; i<mp->get_mg()->get_nr(l); i++) {
363 double xx, xx1, xx2, n1, n2 ;
364 xx1 = ent1(l,k,j,i) ;
365 xx2 = ent2(l,k,j,i) ;
366 xx = delta2(l,k,j,i) ;
368 inside = (!
nbar_ent_p(xx1, xx2, xx, n1, n2)) ;
371 inside1 = (n1 > 0.) ;
373 inside2 = (n2 > 0.) ;
379 n1 = (n1 > 0) ? n1: 0;
380 n2 = (n2 > 0) ? n2: 0;
384 nbar1.
set(l,k,j,i) = n1 ;
385 nbar2.
set(l,k,j,i) = n2 ;
390 inside1 = (n1 > 0.) ;
394 inside2 = (n2 > 0.) ;
396 if (!inside1) n1 = 0. ;
397 if (!inside2) n2 = 0. ;
398 nbar1.
set(l,k,j,i) = n1 ;
399 nbar2.
set(l,k,j,i) = n2 ;
417 Cmp& nbar1,
Cmp& nbar2,
int nzet,
int l_min)
const {
419 assert(ent1.
get_etat() != ETATNONDEF) ;
420 assert(ent2.
get_etat() != ETATNONDEF) ;
421 assert(delta2.
get_etat() != ETATNONDEF) ;
424 assert(mp == ent2.
get_mp()) ;
425 assert(mp == delta2.
get_mp()) ;
426 assert(mp == nbar1.
get_mp()) ;
436 const Mg3d* mg = mp->get_mg() ;
443 nbar1.
annule(0, l_min-1) ;
444 nbar2.
annule(0, l_min-1) ;
447 if (l_min + nzet < nz) {
448 nbar1.
annule(l_min + nzet, nz - 1) ;
449 nbar2.
annule(l_min + nzet, nz - 1) ;
452 int np0 = mp->get_mg()->get_np(0) ;
453 int nt0 = mp->get_mg()->get_nt(0) ;
454 for (
int l=l_min; l<l_min+nzet; l++) {
455 assert(mp->get_mg()->get_np(l) == np0) ;
456 assert(mp->get_mg()->get_nt(l) == nt0) ;
459 for (
int k=0; k<np0; k++) {
460 for (
int j=0; j<nt0; j++) {
462 bool inside1 = true ;
463 bool inside2 = true ;
464 for (
int l=l_min; l< l_min + nzet; l++) {
465 for (
int i=0; i<mp->get_mg()->get_nr(l); i++) {
466 double xx, xx1, xx2, n1, n2 ;
467 xx1 = ent1(l,k,j,i) ;
468 xx2 = ent2(l,k,j,i) ;
469 xx = delta2(l,k,j,i) ;
471 inside = (!
nbar_ent_p(xx1, xx2, xx, n1, n2)) ;
472 inside1 = ((n1 > 0.)&&(xx1>0.)) ;
473 inside2 = ((n2 > 0.)&&(xx2>0.)) ;
476 nbar1.
set(l,k,j,i) = n1 ;
477 nbar2.
set(l,k,j,i) = n2 ;
482 inside1 = (n1 > 0.) ;
484 if (!inside1) n1 = 0. ;
487 inside2 = (n2 > 0.) ;
489 if (!inside2) n2 = 0. ;
490 nbar1.
set(l,k,j,i) = n1 ;
491 nbar2.
set(l,k,j,i) = n2 ;
505 int nzet,
int l_min)
const {
508 assert(ent1.
get_etat() != ETATNONDEF) ;
509 assert(ent2.
get_etat() != ETATNONDEF) ;
510 assert(delta2.
get_etat() != ETATNONDEF) ;
513 assert(mp == ent2.
get_mp()) ;
514 assert(mp == delta2.
get_mp()) ;
517 ener.set_etat_zero() ;
521 ener.allocate_all() ;
523 const Mg3d* mg = mp->get_mg() ;
530 ener.annule(0, l_min-1) ;
532 if (l_min + nzet < nz)
533 ener.annule(l_min + nzet, nz - 1) ;
535 int np0 = mp->get_mg()->get_np(0) ;
536 int nt0 = mp->get_mg()->get_nt(0) ;
537 for (
int l=l_min; l<l_min+nzet; l++) {
538 assert(mp->get_mg()->get_np(l) == np0) ;
539 assert(mp->get_mg()->get_nt(l) == nt0) ;
542 for (
int k=0; k<np0; k++) {
543 for (
int j=0; j<nt0; j++) {
545 bool inside1 = true ;
546 bool inside2 = true ;
547 for (
int l=l_min; l< l_min + nzet; l++) {
548 for (
int i=0; i<mp->get_mg()->get_nr(l); i++) {
549 double xx, xx1, xx2, n1, n2 ;
550 xx1 = ent1(l,k,j,i) ;
551 xx2 = ent2(l,k,j,i) ;
552 xx = delta2(l,k,j,i) ;
554 inside = (!
nbar_ent_p(xx1, xx2, xx, n1, n2)) ;
555 inside1 = ((n1 > 0.)&&(xx1>0.)) ;
556 inside2 = ((n2 > 0.)&&(xx2>0.)) ;
564 inside1 = (n1 > 0.) ;
566 if (!inside1) n1 = 0. ;
569 inside2 = (n2 > 0.) ;
571 if (!inside2) n2 = 0. ;
585 int nzet,
int l_min )
const {
588 assert(ent1.
get_etat() != ETATNONDEF) ;
589 assert(ent2.
get_etat() != ETATNONDEF) ;
590 assert(delta2.
get_etat() != ETATNONDEF) ;
593 assert(mp == ent2.
get_mp()) ;
596 press.set_etat_zero() ;
599 press.allocate_all() ;
601 const Mg3d* mg = mp->get_mg() ;
608 press.annule(0, l_min-1) ;
610 if (l_min + nzet < nz)
611 press.annule(l_min + nzet, nz - 1) ;
613 int np0 = mp->get_mg()->get_np(0) ;
614 int nt0 = mp->get_mg()->get_nt(0) ;
615 for (
int l=l_min; l<l_min+nzet; l++) {
616 assert(mp->get_mg()->get_np(l) == np0) ;
617 assert(mp->get_mg()->get_nt(l) == nt0) ;
620 for (
int k=0; k<np0; k++) {
621 for (
int j=0; j<nt0; j++) {
623 bool inside1 = true ;
624 bool inside2 = true ;
625 for (
int l=l_min; l< l_min + nzet; l++) {
626 for (
int i=0; i<mp->get_mg()->get_nr(l); i++) {
627 double xx, xx1, xx2, n1, n2 ;
628 xx1 = ent1(l,k,j,i) ;
629 xx2 = ent2(l,k,j,i) ;
630 xx = delta2(l,k,j,i) ;
632 inside = (!
nbar_ent_p(xx1, xx2, xx, n1, n2)) ;
633 inside1 = ((n1 > 0.)&&(xx1>0.)) ;
634 inside2 = ((n2 > 0.)&&(xx2>0.)) ;
641 inside1 = (n1 > 0.) ;
643 if (!inside1) n1 = 0. ;
646 inside2 = (n2 > 0.) ;
648 if (!inside2) n2 = 0. ;
662 x2,
int nzet,
int l_min,
double 663 (
Eos_bifluid::*fait)(
double,
double,
double)
const,
666 assert(nbar1.
get_etat() != ETATNONDEF) ;
667 assert(nbar2.
get_etat() != ETATNONDEF) ;
668 assert(x2.
get_etat() != ETATNONDEF) ;
671 assert(mp == nbar2.
get_mp()) ;
679 bool nb1 = nbar1.
get_etat() == ETATQCQ ;
680 bool nb2 = nbar2.
get_etat() == ETATQCQ ;
681 bool bx2 = x2.
get_etat() == ETATQCQ ;
682 const Valeur* vnbar1 = 0x0 ;
683 const Valeur* vnbar2 = 0x0 ;
685 if (nb1) { vnbar1 = &nbar1.
va ;
687 if (nb2) { vnbar2 = &nbar2.
va ;
689 if (bx2) {vx2 = & x2.
va ;
692 const Mg3d* mg = mp->get_mg() ;
703 for (
int l = l_min; l< l_min + nzet; l++) {
712 if (nb1) tnbar1 = vnbar1->
c->
t[l] ;
713 if (nb2) tnbar2 = vnbar2->
c->
t[l] ;
714 if (bx2) tx2 = vx2->
c->
t[l] ;
715 Tbl* tresu = vresu.
c->
t[l] ;
718 if (nb1) nb1b = tnbar1->
get_etat() == ETATQCQ ;
720 if (nb2) nb2b = tnbar2->
get_etat() == ETATQCQ ;
722 if (bx2) bx2b = tx2->
get_etat() == ETATQCQ ;
729 n1 = nb1b ? tnbar1->
t[i] : 0 ;
730 n2 = nb2b ? tnbar2->
t[i] : 0 ;
731 xx = bx2b ? tx2->
t[i] : 0 ;
732 tresu->
t[i] = (this->*fait)(n1, n2, xx ) ;
745 if (l_min + nzet < nz) {
746 resu.
annule(l_min + nzet, nz - 1) ;
751 delta2,
int nzet,
int l_min)
const {
762 delta2,
int nzet,
int l_min)
const {
773 delta2,
int nzet,
int l_min)
const {
Cmp get_Kpp(const Cmp &nbar1, const Cmp &nbar2, const Cmp &x2, int nzet, int l_min=0) const
Computes the derivatives of the energy/(baryonic density 2) .
virtual double get_K12(const double n1, const double n2, const double x) const =0
Computes the derivative of the energy with respect to .
const Map * get_mp() const
Returns the mapping.
double get_m2() const
Return the individual particule mass .
virtual void sauve(FILE *) const
Save in a file.
virtual double get_K22(const double n1, const double n2, const double x) const =0
Computes the derivative of the energy/(baryonic density 2) .
double m_1
Individual particle mass [unit: ].
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Cmp press_ent(const Cmp &ent1, const Cmp &ent2, const Cmp &delta2, int nzet, int l_min=0) const
Computes the pressure from the log-enthalpy fields and the relative velocity.
virtual double nbar_ent_p1(const double ent1) const =0
Computes baryon density out of the log-enthalpy asuming that only fluid 1 is present (virtual functio...
void annule(int l)
Sets the Cmp to zero in a given domain.
virtual int identify() const =0
Returns a number to identify the sub-classe of Eos_bifluid the object belongs to.
Cmp ener_ent(const Cmp &ent1, const Cmp &ent2, const Cmp &delta2, int nzet, int l_min=0) const
Computes the total energy density from the log-enthalpy fields and the relative velocity.
int get_etat() const
Returns the logical state.
void coef_i() const
Computes the physical value of *this.
Base class for coordinate mappings.
Values and coefficients of a (real-value) function.
int get_etat() const
Gives the logical state.
void operator=(const Eos_bifluid &)
Assignment to another Eos_bifluid.
2-fluids equation of state base class.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Cmp get_Knn(const Cmp &nbar1, const Cmp &nbar2, const Cmp &x2, int nzet, int l_min=0) const
Computes the derivatives of the energy/(baryonic density 1) .
virtual double get_K11(const double n1, const double n2, const double x) const =0
Computes the derivative of the energy with respect to (baryonic density 1) .
double m_2
Individual particle mass [unit: ].
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Eos_bifluid()
Standard constructor.
virtual double ener_nbar_p(const double nbar1, const double nbar2, const double delta2) const =0
Computes the total energy density from the baryonic densities and the relative velocity.
void nbar_ent(const Cmp &ent1, const Cmp &ent2, const Cmp &delta2, Cmp &nbar1, Cmp &nbar2, int nzet, int l_min=0) const
Computes both baryon density fields from the log-enthalpy fields and the relative velocity...
double * t
The array of double.
virtual bool nbar_ent_p(const double ent1, const double ent2, const double delta2, double &nbar1, double &nbar2) const =0
Computes both baryon densities from the log-enthalpies (virtual function implemented in the derived c...
Mtbl * c
Values of the function at the points of the multi-grid.
int get_nzone() const
Returns the number of domains.
Analytic equation of state for two fluids (Newtonian case).
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
virtual double nbar_ent_p2(const double ent2) const =0
Computes baryon density out of the log-enthalpy assuming that only fluid 2 is present (virtual functi...
void calcule(const Cmp &nbar1, const Cmp &nbar2, const Cmp &x2, int nzet, int l_min, double(Eos_bifluid::*fait)(double, double, double) const, Cmp &resu) const
General computational method for Cmp 's ( 's).
virtual double press_nbar_p(const double nbar1, const double nbar2, const double delta2) const =0
Computes the pressure from the baryonic densities and the relative velocity.
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
Tbl & set(int l)
Read/write of the value in a given domain.
virtual void calcule_tout(const Cmp &ent1, const Cmp &ent2, const Cmp &delta2, Cmp &nbar1, Cmp &nbar2, Cmp &ener, Cmp &press, int nzet, int l_min=0) const
General computational method for Cmp 's, it computes both baryon densities, energy and pressure profi...
virtual ~Eos_bifluid()
Destructor.
string get_name() const
Returns the EOS name.
int read_variable(const char *fname, const char *var_name, char *fmt, void *varp)
Reads a variable from file.
int get_taille() const
Gives the total size (ie dim.taille)
void set_etat_c_qcq()
Sets the logical state to ETATQCQ (ordinary state) for values in the configuration space (Mtbl c )...
Cmp get_Knp(const Cmp &nbar1, const Cmp &nbar2, const Cmp &x2, int nzet, int l_min=0) const
Computes the derivatives of the energy with respect to .
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's.
Valeur va
The numerical value of the Cmp.
double get_m1() const
Return the individual particule mass .