TAGGED: ansys-mechanical, apdl-coding, energy-balance, source-term
-
-
July 6, 2021 at 10:06 amsolaniSubscriber
Hello everybody,
for my simulation it is necessary to implement chemical reactions and their influence, e.g. the reduction extent of a specific geometry. I want to include this as a source term. How can this be done with Ansys Mechanical?
I tried a few APDL commands. The following code is just a "pseudo code". It has a lot of errors in it. I want to know if the structure and design of the code is okay or if there is any better solution.
! ############################################ ! Getting values and material data ! ############################################ *GET, NumberOfMeshElements, VOLU, 0, COUNT, , Body 1, ! Number of Elements in Body 1 *GET, TimeStepSize, ACTIVE, 0, SOLU, DTIME *SET, CeriaAmount, 1000 ! in mol *SET, ReductionEnthalpy, 500 ! in kJ/mol O ( *SET, OxygenPartialPressure, 100 ! Setting oxygen partial pressure *SET, Temperature, TEMP ! Setting Temperature as a variable *SET, ReductionExtent, 0 ! previous reduction extent ! ############################################ ! Calculation of Source Term ! ############################################ ! Begin of Loop for each time step *DO, t, 0, 10, TimeStepSize ! solve together with transient thermal analysis (convection, radiation, conduction) ReductionExtent = 0.35 * EXP(Temperature) ! goal: storing of previous (t-1) value for later calculation of Rate of Change ! Begin of Loop for each element *DO, i, 1, NumberOfMeshElements, 1 ! needed for each mesh element because each mesh element has a different temperature *GET, MeshElementVolume, VOLU, i, VOLU, , Body 1, ReductionExtentRateOfChange = ReductionExtent(t-1)- ReductionExtent(i) / TimeStepSize S_reaction = - CeriaAmount / MeshElementVolume * ReductionEnthalpy * ReductionExtentRateOfChange ! usally a source term
I am very very thankful for any help. Maybe you have an example of how to add a source term.
Ani
July 7, 2021 at 8:01 am1shanAnsys EmployeeTo my understanding there is no easy way to do this in ANSYS mechanical and might required some programming effort using ANSYS User Programmable Featured (UPF). Do have a look at subroutine usercv and userfx in 2.6. Subroutines for Customizing Loads.There is also a Thermal Mass71 element which support temperature dependent heat generation which might be useful. Nonlinear source terms are easier to handle in FVM codes (with source term linearization) and you fill find a lot of resources to do the same in Fluent.
Regards Ishan.
July 8, 2021 at 7:25 amsolaniSubscriber
Thank you for your answer. I cant open the link you sent - what am I doing wrong?
When you say "easier to handle in FVM codes (with source term linearization)" - this FVM code cant be done in Ansys mechanical - right?
Best regards,
Ani.
July 8, 2021 at 11:14 am1shanAnsys EmployeeCould you try this /forum/discussion/3978/how-to-access-the-ansys-online-help and tell me if you still have issues accessing it. I see some changes in the help documentation(it probably got updated a couple days ago) which might have something to do with it. Anyways do let me know.
Also, "this FVM code cant be done in Ansys mechanical". Right Ansys Mechanical uses FEM while fluent uses FVM.
Regards Ishan.
July 8, 2021 at 1:00 pmsolaniSubscriberIt worked. Thank you for your help. Now I can access it.
However I think it is appropriate to give some further information on what I want to model, since I think your approach is promising but not working because it a surface load.
First of all I am interested in the reduction extent (delta) which can be calculated based on the Arrhenius equation for chemical reactions. In the end the equation looks like this: delta = a * exp(b/T) * (1+ exp(b/T) ^(-1) where a and b are constant.
Second: I am interested in the heat sink due to the reaction. The energy loss can be (for example) calculated by the following simplification:
Constant / Volume per Element that is participating in the chemical reaction * Difference in enthalpy * change of reduction extent per time step
This formula is used (normally) in a energy balancing equation (PDE) which is solved in Matlab for example. Maybe there is a different way of calculating the heat sink & energy loss.
However, the dependence on 1. volume per current element and 2. reducton extent per time step is the reason why I thought about using a "for-loop" with APDL commands. But it seems that the userfx option does this.
Do you think it is possible to calculate the reduction extent and the heat loss due to this reaction with the user programmable features or would it be better to have a look on fluid and linking the thermal simulation to the one in fluid? (since in fluid user defined functions are an option)
Best regards,
Ani
July 9, 2021 at 5:12 am1shanAnsys EmployeeI think it would be easier if you do it using fluent. From what I know there are a few tutorials/examples regarding user defined source terms in fluent help documentation. You could start with these and try modifying them according to your need. Go ahead and post your query under the 'fluids' category. Also before posting read the older posts relevant to this topic this way you can be precise about what you need.
Regards Ishan.
July 9, 2021 at 10:12 amsolaniSubscriber
thank you again for your answer. I think about this but I really need the transient thermal analysis with radiation and heat flux so maybe Fluent is also not the solution.
Best regards,
Ani
July 12, 2021 at 12:35 pmsolaniSubscriber
I found something interesting. What do you think about this as an option?
/forum/discussion/1695/heat-generation
Best regards,
Ani
July 12, 2021 at 12:41 pm1shanAnsys EmployeeIts the Mass71 element, which I have shared in the first comment. Have a look at the documentation. I don't think it supports exponential heat generation term.
Regards Ishan.
July 12, 2021 at 12:45 pmsolaniSubscriber
thank you very much. Maybe there is a work around with curve fitting which is not extremly accurate but still better than nothing.
Best regards,
Ani
July 27, 2021 at 1:54 ampeteroznewmanSubscriberI advised you to look into Fluent in another discussion /forum/discussion/comment/126208#Comment_126208 you replied to in the Structures category, and now I have found that has made the same recommendation in this discussion.
Fluent can do chemical reactions. Here is a page from the theory manual.
As I said in the other discussion, and as Ishan says in this discussion, try posting in the Fluids category, really.
July 27, 2021 at 7:11 amsolaniSubscriber(again ;-))
as I said in the other post you mentioned Fluent is due to some specificiations and the time left for my masterthesis not an option for me.
Thank you anyway.
Ani
Viewing 11 reply threads- The topic ‘Adding something like UDF in Ansys Mechanical / Adding a source term’ is closed to new replies.
Ansys Innovation SpaceTrending discussions- At least one body has been found to have only 1 element in at least 2 directions
- Error when opening saved Workbench project
- How to apply Compression-only Support?
- Geometric stiffness matrix for solid elements
- Frictional No separation contact
- Image to file in Mechanical is bugged and does not show text
- Timestep range set for animation export
- Script Error Code:800a000d
- Elastic limit load, Elastic-plastic limit load
- Element has excessive thickness change, distortion, is turning inside out
Top Contributors-
1406
-
599
-
591
-
555
-
366
Top Rated Tags© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-