ansys / pyfluent

Pythonic interface to Ansys Fluent
https://fluent.docs.pyansys.com
MIT License
257 stars 41 forks source link

Mixture/species transport model API should replicate behavior of materials change/create API #2275

Open ansjsia opened 9 months ago

ansjsia commented 9 months ago

📝 Description of the feature

The settings API calls to create new mixtures for the species transport model should be made consistent with that of the materials change/create API. Currently, it is not possible to create new mixtures without resorting to TUI commands.

💡 Steps for implementing the feature

These are the changes that would need to be implemented, as far as I can tell at this time:

🔗 Useful links and references

No response

dnwillia-work commented 9 months ago

Thanks @ansjsia. I did spend a tiny bit of time trying this myself. I loaded up a single phase case without the species model activated and found the following:

#
# Copy the materials in from the database to make a custom mixture (this works)
#
solver.setup.materials.database.copy_by_name(name="methane", type="fluid")
solver.setup.materials.database.copy_by_name(name="propane", type="fluid")

#
# Turn on species, it works but it also deletes the materials I just copied in from the database
#
solver.setup.models.species.model.option = "species-transport"

#
# Copy the materials again, this seems to work ok
#
solver.setup.materials.database.copy_by_name(name="methane", type="fluid")
solver.setup.materials.database.copy_by_name(name="propane", type="fluid")

#
# Make handles to the newly copied materials
#
methane = solver.setup.materials.fluid["methane"]
propane = solver.setup.materials.fluid["propane"]

#
# Now try and make a mixutre out of those two, this does not work.
#
# This gives that error message and leaves a mixture called 'comgas' in the group
# with three materials: water-vapor, oxygen and nitrogen
#
solver.setup.materials.mixture["comgas"] = { "meth" : methane, "prop" : propane }
RuntimeError: Key 'meth' is invalid

#
# I'm able to delete the incorrectly configured mixture
#
>>> solver.setup.materials.mixture.delete(name_list=["comgas"])

#
# Tried creating like this but it also does not work
#
>>> solver.setup.materials.mixture["comgas"].species.volumetric_species = { "meth" : methane, "prop" : propane }
KeyError: 'comgas is not an allowed Settings objects name.\n'

#
# Tried this to get a blank setup but it also does not work. You get the material with 
# three components: water-vapor, nitrogen and oxygen
#
solver.setup.materials.mixture["comgas"] = {}

So, it's not really clear to me how this is supposed to be working. Related to this are #2016 and #2259.