1D Heat exchanger model with Dyad

Hello, I’m looking for examples of building a dynamic heat exchanger model in Dyad. I have seen some examples with TwoPort fluid models where mdot is the flow variable.

My goal is to create a custom connector that includes enthalpy flow rate (Hdot) as a variable. I understand this requires using the inStream() operator in the component equations to handle the direction of energy flow correctly.

Could anyone share a tutorial or example that demonstrates creating a connector with both flow and stream variables for a 1D thermal-fluid modeling? Is it possible to do this in Dyad, similar to the examples in Modelica? :slight_smile:

For the connector, you can use a FluidPort defined as below:

connector FluidPort
 potential p::Pressure
 flow m_flow::MassFlowRate
 stream h_outflow::SpecificEnthalpy
end

Dyad (through the generated MTK code) already supports instream. You can create a TwoPort component with something along the lines of:

component TwoPort
  port_a = FluidPort()
  port_b = FluidPort)
relations 
# Set relations for m_flow depending on case
  port_a.h_outflow = instream(port_b.h_outflow)
  port_b.h_outflow = instream(port_a.h_outflow)
end

You may be interested in Mike Tiller’s talk at JuliaCon 2025:

2 Likes

Thank you! I’ll watch the video and study more about acausal modeling. :slight_smile:

Sure, feel free to reach out. You may also be interested in: GitHub - DyadLang/ThermalComponents: A library of thermal components for Dyad

1 Like

Hello, I have an additional question that came up while trying a few things on my own.

In the video, my understanding was that (1) the AbstractMedium variable is first defined in Julia, and then (2) when configuring components like Source and Valve in Dyad, it interfaces with Julia to import and use that variable.

Similarly, I would like to create a symbolic function in Julia with the Helmholtz energy-based equation of state for R410a and then import it into Dyad.

Could I get a hint on how to import custom Julia variables or functions into Dyad? The Dyad documentation mentions using Pkg to import external libraries/functions, but I will only be using this for modeling purposes in my local environment.

[Edit] Maybe I can follow the explanations of ‘Modules’.

  1. On AbstractMedium, yes. An example is:

putting the Julia definition here: HydraulicComponents/src/HydraulicComponents.jl at 1e4c8900612b507b772e7249d348dfc0b52cb8f2 · DyadLang/HydraulicComponents · GitHub

marking it as native in Dyad here: HydraulicComponents/dyad/abstract_medium.dyad at main · DyadLang/HydraulicComponents · GitHub

  1. The same repo has examples on using Julia functions:

e.g., you can define them here: HydraulicComponents/src/isothermal_compressible.jl at 1e4c8900612b507b772e7249d348dfc0b52cb8f2 · DyadLang/HydraulicComponents · GitHub

include the file in the HydraulicComponents.jl module/file and then the function is accessible inside Dyad. You may need to symbolically register them.

Thank you! I’ll give it a try :grinning_face: