00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 char eos_bifluid_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_bifluid.C,v 1.16 2008/08/19 06:42:00 j_novak Exp $" ;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 #include <stdlib.h>
00115 #include <math.h>
00116
00117
00118 #include "eos_bifluid.h"
00119 #include "cmp.h"
00120 #include "utilitaires.h"
00121
00122
00123
00124
00125
00126
00127
00128
00129 Eos_bifluid::Eos_bifluid() :
00130 m_1(1), m_2(1)
00131 {
00132 name = NULL;
00133 set_name("") ;
00134 }
00135
00136
00137
00138 Eos_bifluid::Eos_bifluid(const char* name_i, double mass1, double mass2) :
00139 m_1(mass1), m_2(mass2)
00140 {
00141 name = NULL;
00142 set_name(name_i) ;
00143 }
00144
00145
00146
00147 Eos_bifluid::Eos_bifluid(const Eos_bifluid& eos_i) :
00148 m_1(eos_i.m_1), m_2(eos_i.m_2)
00149 {
00150 name = NULL;
00151 set_name(eos_i.name) ;
00152 }
00153
00154
00155
00156 Eos_bifluid::Eos_bifluid(FILE* fich)
00157 {
00158 char dummy [MAX_EOSNAME];
00159 fread(dummy, sizeof(char),MAX_EOSNAME, fich) ;
00160 name = reinterpret_cast<char*>(MyMalloc(strlen(dummy)+1));
00161 strcpy (name, dummy);
00162 fread_be(&m_1, sizeof(double), 1, fich) ;
00163 fread_be(&m_2, sizeof(double), 1, fich) ;
00164
00165 }
00166
00167
00168
00169 Eos_bifluid::Eos_bifluid(char *fname)
00170 {
00171 int res=0;
00172 name = NULL;
00173 char* char_name = const_cast<char*>("name");
00174 char* char_m1 = const_cast<char*>("m_1") ;
00175 char* char_m2 = const_cast<char*>("m_2") ;
00176 res += read_variable (fname, char_name, &name);
00177 res += read_variable (fname, char_m1, m_1);
00178 res += read_variable (fname, char_m2, m_2);
00179
00180 if (res)
00181 {
00182 cerr << "ERROR: Eos_bifluid(char*): could not read either of \
00183 the variables 'name', 'm_1, or 'm_2' from file " << fname << endl;
00184 exit (-1);
00185 }
00186
00187 }
00188
00189
00190
00191
00192
00193
00194
00195 Eos_bifluid::~Eos_bifluid()
00196 {
00197 if (name)
00198 free (name);
00199 }
00200
00201
00202
00203
00204 void Eos_bifluid::operator=(const Eos_bifluid& eosi) {
00205
00206 set_name(eosi.name) ;
00207
00208 m_1 = eosi.m_1;
00209 m_2 = eosi.m_2;
00210
00211 }
00212
00213
00214
00215
00216
00217
00218
00219
00220 void Eos_bifluid::set_name(const char* name_i)
00221 {
00222 if (name)
00223 free (name);
00224
00225 name = reinterpret_cast<char*>(MyMalloc (strlen(name_i) +1));
00226 strcpy(name, name_i);
00227
00228 }
00229
00230 const char* Eos_bifluid::get_name() const {
00231
00232 return name ;
00233
00234 }
00235
00236
00237
00238
00239
00240 void Eos_bifluid::sauve(FILE* fich) const
00241 {
00242 char dummy [MAX_EOSNAME];
00243 int ident = identify() ;
00244
00245 fwrite_be(&ident, sizeof(int), 1, fich) ;
00246
00247 strncpy (dummy, name, MAX_EOSNAME);
00248 dummy[MAX_EOSNAME-1] = 0;
00249 fwrite(dummy, sizeof(char), MAX_EOSNAME, fich );
00250
00251 fwrite_be(&m_1, sizeof(double), 1, fich) ;
00252 fwrite_be(&m_2, sizeof(double), 1, fich) ;
00253
00254 }
00255
00256
00257 ostream& operator<<(ostream& ost, const Eos_bifluid& eqetat) {
00258 ost << eqetat.get_name() << endl ;
00259 ost << " Mean particle 1 mass : " << eqetat.get_m1() << " m_B" << endl ;
00260 ost << " Mean particle 2 mass : " << eqetat.get_m2() << " m_B" << endl ;
00261
00262 eqetat >> ost ;
00263 return ost ;
00264 }
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274 void Eos_bifluid::calcule_tout(const Cmp& ent1, const Cmp& ent2,
00275 const Cmp& delta2, Cmp& nbar1, Cmp& nbar2,
00276 Cmp& ener, Cmp& press,
00277 int nzet, int l_min) const {
00278
00279 assert(ent1.get_etat() != ETATNONDEF) ;
00280 assert(ent2.get_etat() != ETATNONDEF) ;
00281 assert(delta2.get_etat() != ETATNONDEF) ;
00282
00283 const Map* mp = ent1.get_mp() ;
00284 assert(mp == ent2.get_mp()) ;
00285 assert(mp == delta2.get_mp()) ;
00286 assert(mp == ener.get_mp()) ;
00287
00288 if ((ent1.get_etat() == ETATZERO)&&(ent2.get_etat() == ETATZERO)) {
00289 nbar1.set_etat_zero() ;
00290 nbar2.set_etat_zero() ;
00291 ener.set_etat_zero() ;
00292 press.set_etat_zero() ;
00293 return ;
00294 }
00295 nbar1.allocate_all() ;
00296 nbar2.allocate_all() ;
00297 ener.allocate_all() ;
00298 press.allocate_all() ;
00299
00300 const Mg3d* mg = mp->get_mg() ;
00301
00302 int nz = mg->get_nzone() ;
00303
00304
00305
00306 if (l_min > 0) {
00307 nbar1.annule(0, l_min-1) ;
00308 nbar2.annule(0, l_min-1) ;
00309 ener.annule(0, l_min-1) ;
00310 press.annule(0, l_min-1) ;
00311 }
00312
00313 if (l_min + nzet < nz) {
00314 nbar1.annule(l_min + nzet, nz - 1) ;
00315 nbar2.annule(l_min + nzet, nz - 1) ;
00316 ener.annule(l_min + nzet, nz - 1) ;
00317 press.annule(l_min + nzet, nz - 1) ;
00318 }
00319
00320 int np0 = mp->get_mg()->get_np(0) ;
00321 int nt0 = mp->get_mg()->get_nt(0) ;
00322 for (int l=l_min; l<l_min+nzet; l++) {
00323 assert(mp->get_mg()->get_np(l) == np0) ;
00324 assert(mp->get_mg()->get_nt(l) == nt0) ;
00325 }
00326
00327
00328
00329
00330 bool slow_rot_style = false;
00331
00332 if ( identify() == 2 )
00333 {
00334 const Eos_bf_poly_newt *this_eos = dynamic_cast<const Eos_bf_poly_newt*>(this);
00335 if (this_eos -> get_typeos() == 5)
00336 {
00337 slow_rot_style = true;
00338 cout << "DEBUG: using EOS-inversion slow-rot-style!! " << endl;
00339 }
00340 }
00341
00342
00343
00344 for (int k=0; k<np0; k++) {
00345 for (int j=0; j<nt0; j++) {
00346 bool inside = true ;
00347 bool inside1 = true ;
00348 bool inside2 = true ;
00349 for (int l=l_min; l< l_min + nzet; l++) {
00350 for (int i=0; i<mp->get_mg()->get_nr(l); i++) {
00351 double xx, xx1, xx2, n1, n2 ;
00352 xx1 = ent1(l,k,j,i) ;
00353 xx2 = ent2(l,k,j,i) ;
00354 xx = delta2(l,k,j,i) ;
00355 if (inside) {
00356 inside = (!nbar_ent_p(xx1, xx2, xx, n1, n2)) ;
00357
00358 inside1 = (n1 > 0.) ;
00359
00360 inside2 = (n2 > 0.) ;
00361
00362
00363 if (slow_rot_style)
00364 {
00365 inside = true;
00366 n1 = (n1 > 0) ? n1: 0;
00367 n2 = (n2 > 0) ? n2: 0;
00368 }
00369 }
00370 if (inside) {
00371 nbar1.set(l,k,j,i) = n1 ;
00372 nbar2.set(l,k,j,i) = n2 ;
00373 }
00374 else {
00375 if (inside1) {
00376 n1 = nbar_ent_p1(xx1) ;
00377 inside1 = (n1 > 0.) ;
00378 }
00379 if (inside2) {
00380 n2 = nbar_ent_p2(xx2) ;
00381 inside2 = (n2 > 0.) ;
00382 }
00383 if (!inside1) n1 = 0. ;
00384 if (!inside2) n2 = 0. ;
00385 nbar1.set(l,k,j,i) = n1 ;
00386 nbar2.set(l,k,j,i) = n2 ;
00387 }
00388
00389 ener.set(l,k,j,i) = ener_nbar_p(n1, n2, xx) ;
00390 press.set(l,k,j,i) = press_nbar_p(n1, n2, xx) ;
00391
00392 }
00393 }
00394 }
00395 }
00396
00397 }
00398
00399
00400
00401
00402 void Eos_bifluid::nbar_ent(const Cmp& ent1, const Cmp& ent2, const Cmp& delta2,
00403 Cmp& nbar1, Cmp& nbar2, int nzet, int l_min) const {
00404
00405 assert(ent1.get_etat() != ETATNONDEF) ;
00406 assert(ent2.get_etat() != ETATNONDEF) ;
00407 assert(delta2.get_etat() != ETATNONDEF) ;
00408
00409 const Map* mp = ent1.get_mp() ;
00410 assert(mp == ent2.get_mp()) ;
00411 assert(mp == delta2.get_mp()) ;
00412 assert(mp == nbar1.get_mp()) ;
00413
00414 if ((ent1.get_etat() == ETATZERO)&&(ent2.get_etat() == ETATZERO)) {
00415 nbar1.set_etat_zero() ;
00416 nbar2.set_etat_zero() ;
00417 return ;
00418 }
00419 nbar1.allocate_all() ;
00420 nbar2.allocate_all() ;
00421
00422 const Mg3d* mg = mp->get_mg() ;
00423
00424 int nz = mg->get_nzone() ;
00425
00426
00427
00428 if (l_min > 0) {
00429 nbar1.annule(0, l_min-1) ;
00430 nbar2.annule(0, l_min-1) ;
00431 }
00432
00433 if (l_min + nzet < nz) {
00434 nbar1.annule(l_min + nzet, nz - 1) ;
00435 nbar2.annule(l_min + nzet, nz - 1) ;
00436 }
00437
00438 int np0 = mp->get_mg()->get_np(0) ;
00439 int nt0 = mp->get_mg()->get_nt(0) ;
00440 for (int l=l_min; l<l_min+nzet; l++) {
00441 assert(mp->get_mg()->get_np(l) == np0) ;
00442 assert(mp->get_mg()->get_nt(l) == nt0) ;
00443 }
00444
00445 for (int k=0; k<np0; k++) {
00446 for (int j=0; j<nt0; j++) {
00447 bool inside = true ;
00448 bool inside1 = true ;
00449 bool inside2 = true ;
00450 for (int l=l_min; l< l_min + nzet; l++) {
00451 for (int i=0; i<mp->get_mg()->get_nr(l); i++) {
00452 double xx, xx1, xx2, n1, n2 ;
00453 xx1 = ent1(l,k,j,i) ;
00454 xx2 = ent2(l,k,j,i) ;
00455 xx = delta2(l,k,j,i) ;
00456 if (inside) {
00457 inside = (!nbar_ent_p(xx1, xx2, xx, n1, n2)) ;
00458 inside1 = ((n1 > 0.)&&(xx1>0.)) ;
00459 inside2 = ((n2 > 0.)&&(xx2>0.)) ;
00460 }
00461 if (inside) {
00462 nbar1.set(l,k,j,i) = n1 ;
00463 nbar2.set(l,k,j,i) = n2 ;
00464 }
00465 else {
00466 if (inside1) {
00467 n1 = nbar_ent_p1(xx1) ;
00468 inside1 = (n1 > 0.) ;
00469 }
00470 if (!inside1) n1 = 0. ;
00471 if (inside2) {
00472 n2 = nbar_ent_p2(xx2) ;
00473 inside2 = (n2 > 0.) ;
00474 }
00475 if (!inside2) n2 = 0. ;
00476 nbar1.set(l,k,j,i) = n1 ;
00477 nbar2.set(l,k,j,i) = n2 ;
00478 }
00479 }
00480 }
00481 }
00482 }
00483
00484 }
00485
00486
00487
00488
00489
00490 Cmp Eos_bifluid::ener_ent(const Cmp& ent1, const Cmp& ent2, const Cmp& delta2,
00491 int nzet, int l_min) const {
00492
00493 Cmp ener(ent1.get_mp()) ;
00494 assert(ent1.get_etat() != ETATNONDEF) ;
00495 assert(ent2.get_etat() != ETATNONDEF) ;
00496 assert(delta2.get_etat() != ETATNONDEF) ;
00497
00498 const Map* mp = ent1.get_mp() ;
00499 assert(mp == ent2.get_mp()) ;
00500 assert(mp == delta2.get_mp()) ;
00501
00502 if ((ent1.get_etat() == ETATZERO)&&(ent2.get_etat() == ETATZERO)) {
00503 ener.set_etat_zero() ;
00504 return ener;
00505 }
00506
00507 ener.allocate_all() ;
00508
00509 const Mg3d* mg = mp->get_mg() ;
00510
00511 int nz = mg->get_nzone() ;
00512
00513
00514
00515 if (l_min > 0)
00516 ener.annule(0, l_min-1) ;
00517
00518 if (l_min + nzet < nz)
00519 ener.annule(l_min + nzet, nz - 1) ;
00520
00521 int np0 = mp->get_mg()->get_np(0) ;
00522 int nt0 = mp->get_mg()->get_nt(0) ;
00523 for (int l=l_min; l<l_min+nzet; l++) {
00524 assert(mp->get_mg()->get_np(l) == np0) ;
00525 assert(mp->get_mg()->get_nt(l) == nt0) ;
00526 }
00527
00528 for (int k=0; k<np0; k++) {
00529 for (int j=0; j<nt0; j++) {
00530 bool inside = true ;
00531 bool inside1 = true ;
00532 bool inside2 = true ;
00533 for (int l=l_min; l< l_min + nzet; l++) {
00534 for (int i=0; i<mp->get_mg()->get_nr(l); i++) {
00535 double xx, xx1, xx2, n1, n2 ;
00536 xx1 = ent1(l,k,j,i) ;
00537 xx2 = ent2(l,k,j,i) ;
00538 xx = delta2(l,k,j,i) ;
00539 if (inside) {
00540 inside = (!nbar_ent_p(xx1, xx2, xx, n1, n2)) ;
00541 inside1 = ((n1 > 0.)&&(xx1>0.)) ;
00542 inside2 = ((n2 > 0.)&&(xx2>0.)) ;
00543 }
00544 if (inside) {
00545 ener.set(l,k,j,i) = ener_nbar_p(n1, n2, xx) ;
00546 }
00547 else {
00548 if (inside1) {
00549 n1 = nbar_ent_p1(xx1) ;
00550 inside1 = (n1 > 0.) ;
00551 }
00552 if (!inside1) n1 = 0. ;
00553 if (inside2) {
00554 n2 = nbar_ent_p2(xx2) ;
00555 inside2 = (n2 > 0.) ;
00556 }
00557 if (!inside2) n2 = 0. ;
00558 ener.set(l,k,j,i) = ener_nbar_p(n1, n2, 0.) ;
00559 }
00560 }
00561 }
00562 }
00563 }
00564 return ener ;
00565 }
00566
00567
00568
00569
00570 Cmp Eos_bifluid::press_ent(const Cmp& ent1, const Cmp& ent2, const Cmp& delta2,
00571 int nzet, int l_min ) const {
00572
00573 Cmp press(ent1.get_mp()) ;
00574 assert(ent1.get_etat() != ETATNONDEF) ;
00575 assert(ent2.get_etat() != ETATNONDEF) ;
00576 assert(delta2.get_etat() != ETATNONDEF) ;
00577
00578 const Map* mp = ent1.get_mp() ;
00579 assert(mp == ent2.get_mp()) ;
00580
00581 if ((ent1.get_etat() == ETATZERO)&&(ent2.get_etat() == ETATZERO)) {
00582 press.set_etat_zero() ;
00583 return press;
00584 }
00585 press.allocate_all() ;
00586
00587 const Mg3d* mg = mp->get_mg() ;
00588
00589 int nz = mg->get_nzone() ;
00590
00591
00592
00593 if (l_min > 0)
00594 press.annule(0, l_min-1) ;
00595
00596 if (l_min + nzet < nz)
00597 press.annule(l_min + nzet, nz - 1) ;
00598
00599 int np0 = mp->get_mg()->get_np(0) ;
00600 int nt0 = mp->get_mg()->get_nt(0) ;
00601 for (int l=l_min; l<l_min+nzet; l++) {
00602 assert(mp->get_mg()->get_np(l) == np0) ;
00603 assert(mp->get_mg()->get_nt(l) == nt0) ;
00604 }
00605
00606 for (int k=0; k<np0; k++) {
00607 for (int j=0; j<nt0; j++) {
00608 bool inside = true ;
00609 bool inside1 = true ;
00610 bool inside2 = true ;
00611 for (int l=l_min; l< l_min + nzet; l++) {
00612 for (int i=0; i<mp->get_mg()->get_nr(l); i++) {
00613 double xx, xx1, xx2, n1, n2 ;
00614 xx1 = ent1(l,k,j,i) ;
00615 xx2 = ent2(l,k,j,i) ;
00616 xx = delta2(l,k,j,i) ;
00617 if (inside) {
00618 inside = (!nbar_ent_p(xx1, xx2, xx, n1, n2)) ;
00619 inside1 = ((n1 > 0.)&&(xx1>0.)) ;
00620 inside2 = ((n2 > 0.)&&(xx2>0.)) ;
00621 }
00622 if (inside)
00623 press.set(l,k,j,i) = press_nbar_p(n1, n2, xx) ;
00624 else {
00625 if (inside1) {
00626 n1 = nbar_ent_p1(xx1) ;
00627 inside1 = (n1 > 0.) ;
00628 }
00629 if (!inside1) n1 = 0. ;
00630 if (inside2) {
00631 n2 = nbar_ent_p2(xx2) ;
00632 inside2 = (n2 > 0.) ;
00633 }
00634 if (!inside2) n2 = 0. ;
00635 press.set(l,k,j,i) = press_nbar_p(n1, n2, 0. ) ;
00636 }
00637 }
00638 }
00639 }
00640 }
00641 return press ;
00642 }
00643
00644
00645
00646
00647 void Eos_bifluid::calcule(const Cmp& nbar1, const Cmp& nbar2, const Cmp&
00648 x2, int nzet, int l_min, double
00649 (Eos_bifluid::*fait)(double, double, double) const,
00650 Cmp& resu) const {
00651
00652 assert(nbar1.get_etat() != ETATNONDEF) ;
00653 assert(nbar2.get_etat() != ETATNONDEF) ;
00654 assert(x2.get_etat() != ETATNONDEF) ;
00655
00656 const Map* mp = nbar1.get_mp() ;
00657 assert(mp == nbar2.get_mp()) ;
00658
00659
00660 if ((nbar1.get_etat() == ETATZERO)&&(nbar2.get_etat() == ETATZERO)) {
00661 resu.set_etat_zero() ;
00662 return ;
00663 }
00664
00665 bool nb1 = nbar1.get_etat() == ETATQCQ ;
00666 bool nb2 = nbar2.get_etat() == ETATQCQ ;
00667 bool bx2 = x2.get_etat() == ETATQCQ ;
00668 const Valeur* vnbar1 = 0x0 ;
00669 const Valeur* vnbar2 = 0x0 ;
00670 const Valeur* vx2 = 0x0 ;
00671 if (nb1) { vnbar1 = &nbar1.va ;
00672 vnbar1->coef_i() ; }
00673 if (nb2) { vnbar2 = &nbar2.va ;
00674 vnbar2->coef_i() ; }
00675 if (bx2) {vx2 = & x2.va ;
00676 vx2->coef_i() ; }
00677
00678 const Mg3d* mg = mp->get_mg() ;
00679
00680 int nz = mg->get_nzone() ;
00681
00682
00683 resu.set_etat_qcq() ;
00684 Valeur& vresu = resu.va ;
00685 vresu.set_etat_c_qcq() ;
00686 vresu.c->set_etat_qcq() ;
00687
00688
00689 for (int l = l_min; l< l_min + nzet; l++) {
00690
00691 assert(l>=0) ;
00692 assert(l<nz) ;
00693
00694 Tbl* tnbar1 = 0x0 ;
00695 Tbl* tnbar2 = 0x0 ;
00696 Tbl* tx2 = 0x0 ;
00697
00698 if (nb1) tnbar1 = vnbar1->c->t[l] ;
00699 if (nb2) tnbar2 = vnbar2->c->t[l] ;
00700 if (bx2) tx2 = vx2->c->t[l] ;
00701 Tbl* tresu = vresu.c->t[l] ;
00702
00703 bool nb1b = false ;
00704 if (nb1) nb1b = tnbar1->get_etat() == ETATQCQ ;
00705 bool nb2b = false ;
00706 if (nb2) nb2b = tnbar2->get_etat() == ETATQCQ ;
00707 bool bx2b = false ;
00708 if (bx2) bx2b = tx2->get_etat() == ETATQCQ ;
00709 tresu->set_etat_qcq() ;
00710
00711 double n1, n2, xx ;
00712
00713 for (int i=0; i<tnbar1->get_taille(); i++) {
00714
00715 n1 = nb1b ? tnbar1->t[i] : 0 ;
00716 n2 = nb2b ? tnbar2->t[i] : 0 ;
00717 xx = bx2b ? tx2->t[i] : 0 ;
00718 tresu->t[i] = (this->*fait)(n1, n2, xx ) ;
00719 }
00720
00721 }
00722
00723
00724
00725 if (l_min > 0) {
00726 resu.annule(0, l_min-1) ;
00727 }
00728
00729 if (l_min + nzet < nz) {
00730 resu.annule(l_min + nzet, nz - 1) ;
00731 }
00732 }
00733
00734 Cmp Eos_bifluid::get_Knn(const Cmp& nbar1, const Cmp& nbar2, const Cmp&
00735 delta2, int nzet, int l_min) const {
00736
00737 Cmp resu(nbar1.get_mp()) ;
00738
00739 calcule(nbar1, nbar2, delta2, nzet, l_min, &Eos_bifluid::get_K11, resu) ;
00740
00741 return resu ;
00742
00743 }
00744
00745 Cmp Eos_bifluid::get_Knp(const Cmp& nbar1, const Cmp& nbar2, const Cmp&
00746 delta2, int nzet, int l_min) const {
00747
00748 Cmp resu(delta2.get_mp()) ;
00749
00750 calcule(nbar1, nbar2, delta2, nzet, l_min, &Eos_bifluid::get_K12, resu) ;
00751
00752 return resu ;
00753
00754 }
00755
00756 Cmp Eos_bifluid::get_Kpp(const Cmp& nbar1, const Cmp& nbar2, const Cmp&
00757 delta2, int nzet, int l_min) const {
00758
00759 Cmp resu(nbar2.get_mp()) ;
00760
00761 calcule(nbar1, nbar2, delta2, nzet, l_min, &Eos_bifluid::get_K22, resu) ;
00762
00763 return resu ;
00764
00765 }