1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839
|
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# This file is part of Code_Saturne, a general-purpose CFD tool.
#
# Copyright (C) 1998-2021 EDF S.A.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
# -------------------------------------------------------------------------------
import unittest
from code_saturne.model.XMLvariables import Model
from code_saturne.model.XMLengine import *
from code_saturne.model.XMLmodel import *
from code_saturne.model.MainFieldsModel import MainFieldsModel
from code_saturne.model.TurbulenceNeptuneModel import TurbulenceModel
from code_saturne.model.ThermodynamicsModel import ThermodynamicsModel
from code_saturne.model.NotebookModel import NotebookModel
class InterfacialForcesModel(MainFieldsModel, Variables, Model):
"""
This class manages the turbulence objects in the XML file
"""
def __init__(self, case):
"""
Constuctor.
"""
#
# XML file parameters
MainFieldsModel.__init__(self, case)
self.turb_m = TurbulenceModel(case)
self.notebook = NotebookModel(case)
self.case = case
self.XMLClosure = self.case.xmlGetNode('closure_modeling')
self.XMLInterForce = self.XMLClosure.xmlInitNode('interfacial_forces')
self.XMLNodethermo = self.case.xmlGetNode('thermophysical_models')
self.XMLNodeproperty = self.XMLNodethermo.xmlInitNode('properties')
self.__availableturbulentedispersionModelsList = ["none", "LLB_model", "GTD_model"]
self.__availablewallforcesModelList = ["none", "antal", "tomiyama"]
self.__availableContinuousDragModelList = ["Large_Interface_Model", "G_Large_Interface_Model",
"Large_Bubble_Model"]
self.__availableGasDispersedDragModelList = ["ishii", "Wen_Yu"]
self.__availableSolidLiquidDispersedDragModelList = ["inclusions"]
self.__availableAddedMassModelsLists = ["none", "standard", "zuber"]
self.__availableLiftModelsLists = ["none", "coef_cst", "Tomiyama_SMD", "Zeng_Baalbaki"]
# Init freeCouples for forces : criterion checking !
self.__allCouples = []
for i, fieldaId in enumerate(self.getContinuousFieldList()):
for fieldbId in self.getContinuousFieldList()[i + 1:]:
self.__allCouples.append([self.getLabel(fieldaId), self.getLabel(fieldbId), "continuous"])
for fieldbId in self.getDispersedFieldList():
fieldaId = self.getCarrierField(fieldbId)
self.__allCouples.append([self.getLabel(fieldaId), self.getLabel(fieldbId), "dispersed"])
def getAllCouples(self):
return self.__allCouples
# TODO : to remove once the "auto" type of interaction is enabled ?
def getGLIMfields(self):
fields = []
for i, fieldaId in enumerate(self.getContinuousFieldList()):
for fieldbId in self.getContinuousFieldList()[i + 1:]:
if self.getContinuousCouplingModel(fieldaId, fieldbId) == "G_Large_Interface_Model":
fields += [fieldaId, fieldbId]
return fields
def getAvailableContinuousDragModelList(self):
"""
Get available turbulente dispersion list model
"""
return self.__availableContinuousDragModelList
def getAvailableTurbulenteDispersionModelList(self, fieldaId, fieldbId):
"""
Get available turbulente dispersion list model
"""
# Only if : fieldaId is continuous and k-eps or Rij-eps
# fieldbId is dispersed without turbulence
lst = []
if (fieldaId in self.getContinuousFieldList() and fieldbId in self.getDispersedFieldList()) :
if (self.turb_m.isSecondOrderTurbulenceModel(fieldaId) and self.turb_m.getTurbulenceModel(fieldbId) == "none") :
lst = self.__availableturbulentedispersionModelsList
else :
lst = ["none"]
else :
lst = ["none"]
return lst
def getAvailableWallForcesModelList(self, fieldaId, fieldbId):
"""
Get available wall forces list model
"""
# only for bubbles in water
lst = []
if ((fieldbId in self.getDispersedFieldList()) and self.getFieldNature(fieldbId) == "gas") :
lst = self.__availablewallforcesModelList
else :
lst = ["none"]
return lst
def getAvailableDragModels(self, fieldaId, fieldbId) :
"""
return Model list according to fields criterion
"""
# field A is continuous and field B is dispersed
self.isInList(fieldaId,self.getContinuousFieldList())
self.isInList(fieldbId,self.getDispersedFieldList())
if (self.getFieldNature(fieldaId) == "liquid") and (self.getFieldNature(fieldbId) == "solid") :
return self.__availableSolidLiquidDispersedDragModelList
else :
predefined_flow = self.getPredefinedFlow()
if predefined_flow == "boiling_flow":
return ["ishii"]
elif predefined_flow == "droplet_flow":
return ["Wen_Yu"]
else:
return self.__availableGasDispersedDragModelList
def getAvailableAddedMassModels(self) :
"""
return Model list according to fields criterion
"""
return self.__availableAddedMassModelsLists
def getAvailableLiftModels(self) :
"""
return Model list according to fields criterion
"""
return self.__availableLiftModelsLists
def defaultValues(self):
default = {}
predefined_flow = self.getPredefinedFlow()
default['gasdisperseddragmodel'] = 'ishii'
default['liquidsoliddisperseddragmodel'] = 'inclusions'
default['addedmassmodel'] = 'zuber'
default['liftmodel'] = 'Tomiyama_SMD'
default['turbulent_dispersion_model'] = "none"
default['wallforcemodel'] = 'tomiyama'
default['nowallforcemodel'] = 'none'
if predefined_flow == "boiling_flow":
GTD_condition_1 = (self.turb_m.getTurbulenceModel("1") in
["k-epsilon",
"k-epsilon_linear_production",
"rij-epsilon_ssg'",
"rij-epsilon_ebrsm"])
GTD_condition_2 = (self.turb_m.getTurbulenceModel("2") == "none")
if GTD_condition_1 and GTD_condition_2:
default['turbulent_dispersion_model'] = "GTD_model"
elif predefined_flow == "droplet_flow":
default['gasdisperseddragmodel'] = "Wen_Yu"
default['liftmodel'] = "Zeng_Baalbaki"
default['addedmassmodel'] = "none"
default['wallforcemodel'] = "none"
elif predefined_flow == "particles_flow":
default['gasdisperseddragmodel'] = 'ishii'
default['liftmodel'] = "Zeng_Baalbaki"
default['wallforcemodel'] = 'none'
else:
pass
return default
def defaultValuesContinuous(self):
default = {}
predefined_flow = self.getPredefinedFlow()
default['continuousdragmodel'] = 'Large_Interface_Model'
default['BubblesForLIM'] = 'off'
default['InterfaceSharpening'] = 'none'
default["SurfaceTension"] = "none"
if predefined_flow == "free_surface":
pass
elif predefined_flow == "multiregime":
default['continuousdragmodel'] = "G_Large_Interface_Model"
default['BubblesForLIM'] = "on"
else:
pass
return default
def setDefaultParameters(self, field_id_a, field_id_b):
predefined_flow = self.getPredefinedFlow()
# Dispersed models
if predefined_flow in ["boiling_flow", "droplet_flow", "particles_flow"]:
default = self.defaultValues()
if (self.getFieldNature(field_id_a) == "liquid") and (self.getFieldNature(field_id_b) == "solid"):
self.setDragModel(field_id_a, field_id_b, default["liquidsoliddisperseddragmodel"])
else:
self.setDragModel(field_id_a, field_id_b, default["gasdisperseddragmodel"])
self.setLiftModel(field_id_a, field_id_b, default["liftmodel"])
self.setAddMassModel(field_id_a, field_id_b, default["addedmassmodel"])
self.setTurbDispModel(field_id_a, field_id_b, default["turbulent_dispersion_model"])
self.setWallForceModel(field_id_a, field_id_b, default["wallforcemodel"])
# Continuous models
elif predefined_flow in ["free_surface", "multiregime"]:
default = self.defaultValuesContinuous()
self.setContinuousCouplingModel(field_id_a, field_id_b, default["continuousdragmodel"])
self.setBubblesForLIMStatus(field_id_a, field_id_b, default["BubblesForLIM"])
self.setInterfaceSharpeningModel(field_id_a, field_id_b, default["InterfaceSharpening"])
self.setSurfaceTensionModel(field_id_a, field_id_b, default["SurfaceTension"])
# User defined flow : do nothing for now
else:
pass
@Variables.noUndo
def getForceList(self) :
"""
return list of field couple for forces
"""
lst = []
for node in self.XMLInterForce.xmlGetNodeList('force') :
couple=[node['field_id_a'], node['field_id_b']]
lst.append(couple)
return lst
def __updatedrag(self, fieldaId, fieldbId) :
"""
update drag model after fieldIdChange
"""
model = ""
model = self.defaultValues()['gasdisperseddragmodel']
if (self.getFieldNature(fieldaId) == "liquid") and (self.getFieldNature(fieldbId == "solid")):
model = self.defaultValues()['liquidsoliddisperseddragmodel']
self.setDragModel(fieldaId, fieldbId, model)
if model != "none" :
Variables(self.case).setNewVariableProperty("property", "", self.XMLNodeproperty, fieldbId, "drag_coefficient", "drag_coef"+str(fieldbId))
else :
Variables(self.case).removeVariableProperty("property", self.XMLNodeproperty, fieldbId, "drag_coefficient")
def __updateWallForce(self, fieldaId, fieldbId) :
"""
update wall force after fieldIdChange
"""
model = self.getWallForceModel(fieldaId, fieldbId)
if model not in self.getAvailableWallForcesModelList(fieldaId, fieldbId) :
model = self.getAvailableWallForcesModelList(fieldaId, fieldbId)[0]
self.setWallForceModel(fieldaId, fieldbId, model)
def __updateTurbulentDispersion(self, fieldaId, fieldbId) :
"""
update turbulent dispersion after fieldIdChange
"""
model = self.getTurbDispModel(fieldaId, fieldbId)
if model not in self.getAvailableTurbulenteDispersionModelList(fieldaId, fieldbId) :
model = self.getAvailableTurbulenteDispersionModelList(fieldaId, fieldbId)[0]
self.setTurbDispModel(fieldaId, fieldbId, model)
@Variables.undoGlobal
def setDragModel(self, fieldaId, fieldbId, model) :
"""
set drag model for a couple fieldId
"""
self.isInList(model, self.getAvailableDragModels(fieldaId, fieldbId))
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
ChildNode = node.xmlInitChildNode('drag_model')
ChildNode['model'] = model
if model != "none":
Variables(self.case).setNewVariableProperty("property", "", self.XMLNodeproperty, fieldbId,
"drag_coefficient", "drag_coef" + str(fieldbId))
else:
Variables(self.case).removeVariableProperty("property", self.XMLNodeproperty, fieldbId, "drag_coefficient")
@Variables.noUndo
def getDragModel(self, fieldaId, fieldbId) :
"""
get drag model for a couple fieldId
"""
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
childNode = node.xmlGetNode('drag_model')
if childNode == None :
model = self.defaultValues()['gasdisperseddragmodel']
if (self.getFieldNature(fieldaId) == "liquid") and (self.getFieldNature(fieldbId) == "solid"):
model = self.defaultValues()['liquidsoliddisperseddragmodel']
self.setDragModel(fieldaId, fieldbId, model)
model = node.xmlGetNode('drag_model')['model']
return model
@Variables.undoLocal
def setAddMassModel(self, fieldaId, fieldbId, model) :
"""
set added mass model for a couple fieldId
"""
self.isInList(model, self.getAvailableAddedMassModels())
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
ChildNode = node.xmlInitChildNode('added_mass')
ChildNode['model'] = model
@Variables.noUndo
def getAddMassModel(self, fieldaId, fieldbId) :
"""
get added mass model for a couple fieldId
"""
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
childNode = node.xmlGetNode('added_mass')
if childNode == None :
model = self.defaultValues()['addedmassmodel']
self.setAddMassModel(fieldaId, fieldbId, model)
model = node.xmlGetNode('added_mass')['model']
return model
@Variables.undoLocal
def setLiftModel(self, fieldaId, fieldbId, model) :
"""
set lift model for a couple fieldId
"""
self.isInList(model, self.getAvailableLiftModels())
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
ChildNode = node.xmlInitChildNode('lift_model')
ChildNode['model'] = model
@Variables.noUndo
def getLiftModel(self, fieldaId, fieldbId) :
"""
get lift model for a couple fieldId
"""
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
childNode = node.xmlGetNode('lift_model')
if childNode == None :
model = self.defaultValues()['liftmodel']
self.setLiftModel(fieldaId, fieldbId, model)
model = node.xmlGetNode('lift_model')['model']
return model
@Variables.undoLocal
def setWallForceModel(self, fieldaId, fieldbId, model) :
"""
set wall force model for a couple fieldId
"""
self.isInList(model, self.getAvailableWallForcesModelList(fieldaId, fieldbId))
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
ChildNode = node.xmlInitChildNode('wall_force_model')
ChildNode['model'] = model
@Variables.noUndo
def getWallForceModel(self, fieldaId, fieldbId) :
"""
get wall force model for a couple fieldId
"""
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
childNode = node.xmlGetNode('wall_force_model')
if childNode == None :
if len(self.getAvailableWallForcesModelList(fieldaId, fieldbId)) > 1:
model = self.defaultValues()['wallforcemodel']
else:
model = self.defaultValues()['nowallforcemodel']
self.setWallForceModel(fieldaId, fieldbId, model)
model = node.xmlGetNode('wall_force_model')['model']
return model
@Variables.undoLocal
def setTurbDispModel(self, fieldaId, fieldbId, model) :
"""
set turbulent dispersion model for a couple fieldId
"""
self.isInList(model, self.getAvailableTurbulenteDispersionModelList(fieldaId, fieldbId))
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
ChildNode = node.xmlInitChildNode('turbulent_dispersion_model')
ChildNode['model'] = model
@Variables.noUndo
def getTurbDispModel(self, fieldaId, fieldbId) :
"""
get turbulent dispersion model for a couple fieldId
"""
node = self.XMLInterForce.xmlInitChildNode('force', field_id_a=fieldaId, field_id_b=fieldbId)
childNode = node.xmlGetNode('turbulent_dispersion_model')
if childNode == None :
model = self.defaultValues()['turbulent_dispersion_model']
self.setTurbDispModel(fieldaId, fieldbId, model)
model = node.xmlGetNode('turbulent_dispersion_model')['model']
return model
@Variables.undoGlobal
def deleteForce(self, fieldaId, fieldbId) :
"""
suppress force
"""
self.isInList([fieldaId, fieldbId], self.getForceList())
node = self.XMLInterForce.xmlGetNode('force', field_id_a = fieldaId, field_id_b = fieldbId)
node.xmlRemoveNode()
@Variables.undoGlobal
def setContinuousCouplingModel(self, field_id_a, field_id_b, model):
"""
set turbulent dispersion model for a couple fieldId
"""
self.isInList(model, self.getAvailableContinuousDragModelList())
ChildNode = self.XMLInterForce.xmlInitChildNode('continuous_field_momentum_transfer',
field_id_a=field_id_a,
field_id_b=field_id_b)
ChildNode['model'] = model
if model != "separate_phases":
ChildNode2 = ChildNode.xmlGetChildNode('gradP_correction')
if ChildNode2 != None:
ChildNode2.xmlRemoveNode()
ChildNode2 = ChildNode.xmlGetChildNode('gradP_correction_model')
if ChildNode2 != None:
ChildNode2.xmlRemoveNode()
if model not in ["Large_Interface_Model", "G_Large_Interface_Model"]:
ChildNode2 = ChildNode.xmlGetChildNode('BubblesForLIM')
if ChildNode2 != None:
ChildNode2.xmlRemoveNode()
if model == "none":
ChildNode2 = ChildNode.xmlGetChildNode('InterfaceSharpening')
if ChildNode2 != None:
ChildNode2.xmlRemoveNode()
if model == "G_Large_Interface_Model":
self.setBubblesForLIMStatus(field_id_a, field_id_b, "on")
@Variables.noUndo
def getContinuousCouplingModel(self, field_id_a, field_id_b):
"""
get turbulent dispersion model for a couple fieldId
"""
ChildNode = self.XMLInterForce.xmlGetChildNode('continuous_field_momentum_transfer', field_id_a=field_id_a,
field_id_b=field_id_b)
# separate_phases model has been removed from the GUI!
# Hence if the test leads to separate phases we set the model to none...
if ChildNode == None:
model = self.defaultValuesContinuous()['continuousdragmodel']
self.setContinuousCouplingModel(field_id_a, field_id_b, model)
ChildNode = self.XMLInterForce.xmlGetChildNode('continuous_field_momentum_transfer', field_id_a=field_id_a,
field_id_b=field_id_b)
elif ChildNode['model'] == 'separate_phases':
self.setContinuousCouplingModel(field_id_a, field_id_b, 'none')
ChildNode = self.XMLInterForce.xmlGetChildNode('continuous_field_momentum_transfer', field_id_a=field_id_a,
field_id_b=field_id_b)
model = ChildNode['model']
if model == None:
model = "none"
return model
@Variables.undoLocal
def setBubblesForLIMStatus(self, field_id_a, field_id_b, status):
node = self.XMLInterForce.xmlGetChildNode('continuous_field_momentum_transfer',
field_id_a=field_id_a,
field_id_b=field_id_b)
old_status = node.xmlGetString('BubblesForLIM')
node.xmlSetData('BubblesForLIM', status)
mfm = MainFieldsModel(self.case)
if mfm.getPredefinedFlow() == 'free_surface':
fieldId = self.getContinuousFieldList()[1]
if status == "off" and old_status:
node = self.XMLClosure.xmlGetChildNode('interfacial_area_diameter')
if node:
node.xmlRemoveNode()
Variables(self.case).removeVariableProperty("property",
self.XMLNodeproperty,
fieldId,
"diameter")
Variables(self.case).removeVariableProperty("property",
self.XMLNodeproperty,
fieldId,
"drift_component")
elif status == "on":
field_name = MainFieldsModel(self.case).getFieldLabelsList()[int(fieldId)-1]
Variables(self.case).setNewVariableProperty('property', '',
self.XMLNodeproperty,
fieldId,
'diameter',
'diam_'+field_name)
Variables(self.case).setNewVariableProperty('property', '',
self.XMLNodeproperty,
fieldId,
'drift_component',
'drift_component_'+field_name)
@Variables.noUndo
def getBubblesForLIMStatus(self, field_id_a, field_id_b):
node = self.XMLInterForce.xmlGetChildNode('continuous_field_momentum_transfer',
field_id_a=field_id_a,
field_id_b=field_id_b)
if node == None:
node = self.XMLInterForce.xmlInitChildNode('continuous_field_momentum_transfer',
field_id_a=field_id_a,
field_id_b=field_id_b)
ChildNode = node.xmlGetChildNode('BubblesForLIM')
if ChildNode == None:
status = self.defaultValuesContinuous()['BubblesForLIM']
self.setBubblesForLIMStatus(field_id_a, field_id_b, status)
status = node.xmlGetString('BubblesForLIM')
return status
@Variables.undoLocal
def setInterfaceSharpeningModel(self, field_id_a, field_id_b, status):
node = self.XMLInterForce.xmlGetChildNode('continuous_field_momentum_transfer',
field_id_a=field_id_a,
field_id_b=field_id_b)
node.xmlSetData('InterfaceSharpening', status)
@Variables.noUndo
def getInterfaceSharpeningModel(self, field_id_a, field_id_b):
node = self.XMLInterForce.xmlGetChildNode('continuous_field_momentum_transfer',
field_id_a=field_id_a,
field_id_b=field_id_b)
ChildNode = node.xmlGetChildNode('InterfaceSharpening')
if ChildNode == None:
status = self.defaultValuesContinuous()['InterfaceSharpening']
self.setInterfaceSharpeningModel(field_id_a, field_id_b, status)
status = node.xmlGetString('InterfaceSharpening')
return status
@Variables.undoLocal
def setSurfaceTensionModel(self, field_id_a, field_id_b, model):
node = self.XMLInterForce.xmlGetChildNode('continuous_field_momentum_transfer',
field_id_a=field_id_a,
field_id_b=field_id_b)
st_node = node.xmlInitChildNode('SurfaceTension')
st_node.xmlSetData('model', model)
@Variables.noUndo
def getSurfaceTensionModel(self, field_id_a, field_id_b):
node = self.XMLInterForce.xmlGetChildNode('continuous_field_momentum_transfer',
field_id_a=field_id_a,
field_id_b=field_id_b)
st_node = node.xmlGetChildNode('SurfaceTension')
if st_node == None:
st_node = node.xmlInitChildNode('SurfaceTension')
model = self.defaultValuesContinuous()['SurfaceTension']
self.setSurfaceTensionModel(field_id_a, field_id_b, model)
model = st_node.xmlGetString('model')
return model
#-------------------------------------------------------------------------------
# DefineUsersScalars test case
#-------------------------------------------------------------------------------
class InterfacialForcesTestCase(ModelTest):
"""
"""
def checkInterfacialForcesInstantiation(self):
"""Check whether the InterfaciallForcesModel class could be instantiated"""
model = None
model = InterfacialForcesModel(self.case)
assert model != None, 'Could not instantiate InterfacialForcesModel'
def checkGetAvailableContinuousDragModelList(self):
"""Check whether the InterfacialEnthalpyModel class could get the AvailableContinuousDragModelList"""
mdl = InterfacialForcesModel(self.case)
assert mdl.getAvailableContinuousDragModelList() == ["none", "Large_Interface_Model", "G_Large_Interface_Model",
"Large_Bubble_Model"], \
'Could not get AvailableContinuousDragModelList'
def checkGetAvailableTurbulenteDispersionModelList(self):
"""Check whether the InterfacialEnthalpyModel class could get the AvailableTurbulenteDispersionModelList"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
TurbulenceModel(self.case).setTurbulenceModel('1','k-epsilon')
TurbulenceModel(self.case).setTurbulenceModel('2','none')
mdl = InterfacialForcesModel(self.case)
assert mdl.getAvailableTurbulenteDispersionModelList('1','2') == ["none","LLB_model","GTD_model"],\
'Could not get AvailableTurbulenteDispersionModelList'
def checkGetAvailableWallForcesModelList(self):
"""Check whether the InterfacialEnthalpyModel class could get the AvailableWallForcesModelList"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
ThermodynamicsModel(self.case).setMaterials('2','Water')
mdl = InterfacialForcesModel(self.case)
assert mdl.getAvailableWallForcesModelList('1','2') == ["none", "antal", "tomiyama"],\
'Could not get AvailableWallForcesModelList'
def checkGetAvailableDragModels(self):
"""Check whether the InterfacialEnthalpyModel class could get the AvailableDragModels"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
mdl = InterfacialForcesModel(self.case)
assert mdl.getAvailableDragModels('1','2') == ["none", "ishii", "Wen_Yu"],\
'Could not get AvailableDragModels'
MainFieldsModel(self.case).setFieldNature('2','solid')
assert mdl.getAvailableDragModels('1','2') == ["none", "inclusions"],\
'Could not get AvailableDragModels'
def checkGetAvailableAddedMassModels(self):
"""Check whether the InterfacialEnthalpyModel class could get the AvailableAddedMassModels"""
mdl = InterfacialForcesModel(self.case)
assert mdl.getAvailableAddedMassModels() == ["none", "standard", "zuber"],\
'Could not get AvailableAddedMassModels'
def checkGetAvailableLiftModels(self):
"""Check whether the InterfacialEnthalpyModel class could get the AvailableLiftModels"""
mdl = InterfacialForcesModel(self.case)
assert mdl.getAvailableLiftModels() == ["none", "coef_cst", "Tomiyama_SMD", "Zeng_Baalbaki"], \
'Could not get AvailableLiftModels'
def checkGetForceList(self):
"""Check whether the InterfacialEnthalpyModel class could get force list"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
mdl = InterfacialForcesModel(self.case)
assert mdl.getForceList() == [['1', '2']],\
'Could not get force list'
def checkGetandSetDragModel(self):
"""Check whether the InterfacialEnthalpyModel class could set and get DragModel"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
mdl = InterfacialForcesModel(self.case)
mdl.setDragModel('1','2','ishii')
doc = '''<interfacial_forces>
<force field_id_a="1" field_id_b="2">
<drag_model model="ishii"/>
<added_mass model="none"/>
<lift_model model="none"/>
<wall_force_model model="none"/>
<turbulent_dispersion_model model="none"/>
</force>
</interfacial_forces>'''
assert mdl.XMLInterForce == self.xmlNodeFromString(doc),\
'Could not set DragModel'
assert mdl.getDragModel('1','2') == 'ishii',\
'Could not get DragModel'
def checkGetandSetAddMassModel(self):
"""Check whether the InterfacialEnthalpyModel class could set and get AddMassModel"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
mdl = InterfacialForcesModel(self.case)
mdl.setAddMassModel('1','2','standard')
doc = '''<interfacial_forces>
<force field_id_a="1" field_id_b="2">
<drag_model model="ishii"/>
<added_mass model="standard"/>
<lift_model model="none"/>
<wall_force_model model="none"/>
<turbulent_dispersion_model model="none"/>
</force>
</interfacial_forces>'''
assert mdl.XMLInterForce == self.xmlNodeFromString(doc),\
'Could not set AddMassModel'
assert mdl.getAddMassModel('1','2') == 'standard',\
'Could not set AddMassModel'
def checkGetandSetLiftModel(self):
"""Check whether the InterfacialEnthalpyModel class could set and get LiftModel"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
mdl = InterfacialForcesModel(self.case)
mdl.setLiftModel('1','2','coef_cst')
doc = '''<interfacial_forces>
<force field_id_a="1" field_id_b="2">
<drag_model model="ishii"/>
<added_mass model="none"/>
<lift_model model="coef_cst"/>
<wall_force_model model="none"/>
<turbulent_dispersion_model model="none"/>
</force>
</interfacial_forces>'''
assert mdl.XMLInterForce == self.xmlNodeFromString(doc),\
'Could not set LiftModel'
assert mdl.getLiftModel('1','2') == 'coef_cst',\
'Could not set LiftModel'
def checkGetandSetWallForceModel(self):
"""Check whether the InterfacialEnthalpyModel class could set and get WallForceModel"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
ThermodynamicsModel(self.case).setMaterials('2','Water')
mdl = InterfacialForcesModel(self.case)
mdl.setWallForceModel('1','2','antal')
doc = '''<interfacial_forces>
<force field_id_a="1" field_id_b="2">
<drag_model model="ishii"/>
<added_mass model="none"/>
<lift_model model="none"/>
<wall_force_model model="antal"/>
<turbulent_dispersion_model model="none"/>
</force>
</interfacial_forces>'''
assert mdl.XMLInterForce == self.xmlNodeFromString(doc),\
'Could not set WallForceModel'
assert mdl.getWallForceModel('1','2') == 'antal',\
'Could not set WallForceModel'
def checkGetandSetTurbDispModel(self):
"""Check whether the InterfacialEnthalpyModel class could set and get TurbDispModel"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
TurbulenceModel(self.case).setTurbulenceModel('1','k-epsilon')
TurbulenceModel(self.case).setTurbulenceModel('2','none')
mdl = InterfacialForcesModel(self.case)
mdl.setTurbDispModel('1','2','LLB_model')
doc = '''<interfacial_forces>
<force field_id_a="1" field_id_b="2">
<drag_model model="ishii"/>
<added_mass model="none"/>
<lift_model model="none"/>
<wall_force_model model="none"/>
<turbulent_dispersion_model model="LLB_model"/>
</force>
</interfacial_forces>'''
assert mdl.XMLInterForce == self.xmlNodeFromString(doc),\
'Could not set TurbDispModel'
assert mdl.getTurbDispModel('1','2') == 'LLB_model',\
'Could not set TurbDispModel'
def checkdeleteForce(self):
"""Check whether the InterfacialEnthalpyModel class could deleteForce"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'dispersed', 'gas', 'on', 'on', 'off', 2)
mdl = InterfacialForcesModel(self.case)
mdl.deleteForce('1','2')
doc = '''<interfacial_forces/>'''
assert mdl.XMLInterForce == self.xmlNodeFromString(doc),\
'Could not delete Force'
def checkGetandSetContinuousCouplingModel(self):
"""Check whether the InterfacialEnthalpyModel class could set and get ContinuousCouplingModel"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'continuous', 'gas', 'on', 'on', 'off', 2)
mdl = InterfacialForcesModel(self.case)
mdl.setContinuousCouplingModel('1', '2', 'Large_Interface_Model')
doc = '''<interfacial_forces>
<continuous_field_momentum_transfer model="Large_Interface_Model"/>
</interfacial_forces>'''
assert mdl.XMLInterForce == self.xmlNodeFromString(doc), \
'Could not set ContinuousCouplingModel'
assert mdl.getContinuousCouplingModel('1', '2') == 'Large_Interface_Model', \
'Could not get ContinuousCouplingModel'
def checkGetandSetTurbulenceEffectStatus(self):
"""Check whether the InterfacialEnthalpyModel class could set and get TurbulenceEffectStatus"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'continuous', 'gas', 'on', 'on', 'off', 2)
mdl = InterfacialForcesModel(self.case)
mdl.setContinuousCouplingModel('1', '2', 'Large_Interface_Model')
doc = '''<interfacial_forces>
<continuous_field_momentum_transfer model="Large_Interface_Model">
<TurbulenceEffect>
on
</TurbulenceEffect>
</continuous_field_momentum_transfer>
</interfacial_forces>'''
assert mdl.XMLInterForce == self.xmlNodeFromString(doc),\
'Could not set TurbulenceEffectStatus'
assert mdl.getTurbulenceEffectStatus() == 'on',\
'Could not set TurbulenceEffectStatus'
def checkGetandSetFrictionStatus(self):
"""Check whether the InterfacialEnthalpyModel class could set and get FrictionStatus"""
MainFieldsModel(self.case).addDefinedField('1', 'field1', 'continuous', 'liquid', 'on', 'on', 'off', 1)
MainFieldsModel(self.case).addDefinedField('2', 'field2', 'continuous', 'gas', 'on', 'on', 'off', 2)
mdl = InterfacialForcesModel(self.case)
mdl.setContinuousCouplingModel('1', '2', 'Large_Interface_Model')
mdl.setFrictionStatus('on')
doc = '''<interfacial_forces>
<continuous_field_momentum_transfer model="Large_Interface_Model">
<WaweRoughness>
on
</WaweRoughness>
</continuous_field_momentum_transfer>
</interfacial_forces>'''
assert mdl.XMLInterForce == self.xmlNodeFromString(doc),\
'Could not set FrictionStatus'
assert mdl.getFrictionStatus() == 'on',\
'Could not set FrictionStatus'
def suite():
testSuite = unittest.makeSuite(InterfacialForcesTestCase, "check")
return testSuite
def runTest():
print("InterfacialForcesTestCase")
runner = unittest.TextTestRunner()
runner.run(suite())
|