Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Create custom TMAP syntax #8

Open
lindsayad opened this issue May 4, 2021 · 12 comments
Open

Create custom TMAP syntax #8

lindsayad opened this issue May 4, 2021 · 12 comments
Labels
T: Task An enhancement to the software.

Comments

@lindsayad
Copy link
Member

We want TMAP8 to feel like previous TMAPs, which means it should feel like a system code. In the MOOSE world probably the most similar comparison is THM. So we need to figure out what our blocks should be titled and look like. We will track our progress here.

@humrpw do you want to weigh-in on what you want the blocks to be? Should I simply copy all the block headers from the TMAP4 manual?

@humrpw
Copy link

humrpw commented Jun 9, 2021

My general approach here is to modify THM-like input and objects, and modify as appropriate to capture necessary TMAP input and terminology. I'm still looking at BCs and "heat transfer" components in THM and figuring out what their mass transfer analogues should be in TMAP, but here's what enclosures and structures should look like:

registerMooseObject("TMAPApp", Enclosure);

InputParameters
Enclosure::validParams()
{
  params.addRequiredParam<std::string>("type", "Enclosure type ('functional' or 'boundary')");
  params.addRequiredParam<std::string>("material", "Fluid material name");
  params.addRequiredParam<FunctionName>("volume", "Volume of enclosure [m^3]");
  params.addRequiredParam<FunctionName>("temperature", "Enclosure temperature [K]");
  params.addRequiredParam<FunctionName>("pressure", "Enclosure pressure [Pa]");
  params.addParam<FunctionName>("D_h", "Hydraulic diameter [m]"); // required if mass transfer correlation is to be used                               
  params.addRequiredParam<std::vector<unsigned int>>("n_axial_elems", "Number of elements in each subsection along the main axis");

  return params;
}

registerMooseObject("TMAPApp", PlateStructure);

InputParameters
PlateStructure::validParams()
{
  params.addRequiredParam<std::vector<unsigned int>>("n_axial_elems", "Number of elements in each subsection along the main axis");
  params.addParam<std::vector<Real>>("length", "Length of each axial section of the structure [m]"); // optional, for mass transfer                    
  params.addRequiredParam<std::vector<Real>>("depths", "Depth of each transverse region [m]");
  params.addRequiredParam<std::vector<unsigned int>>("n_depth_elems", "Number of elements of each transverse region");
  params.addRequiredParam<std::vector<std::string>>("materials","Material name for each transverse region");
  params.addParam<Real>("mult", 1.0, "Structure multiplicity; Number of identical structures represented by this one");
  params.addRequiredParam<Real>("area", "Surface area of the plate [m^3]");
  params.addParam<FunctionName>("initial_T", "Initial temperature [K]");

  return params;
}

registerMooseObject("TMAPApp", CylindricalStructure);

InputParameters
CylindricalStructure::validParams()
{
  params.addRequiredParam<std::vector<unsigned int>>("n_axial_elems", "Number of elements in each subsection along the main axis");
  params.addParam<std::vector<Real>>("length", "Length of each axial section of the structure [m]"); // optional, for mass transfer                    
  params.addRequiredParam<std::vector<Real>>("depths", "Depth of each radial region [m]");
  params.addRequiredParam<std::vector<unsigned int>>("n_radial_elems", "Number of elements in each radial region");
  params.addRequiredParam<std::vector<std::string>>("materials","Material name for each radial region");
  params.addParam<Real>("mult", 1.0, "Structure multiplicity; Number of identical structures represented by this one");
  params.addParam<FunctionName>("initial_T", "Initial temperature [K]");
  // Both of the following optional; omission implies solid cylinder.  For annulus (i.e. pipe), at least one required.                                 
  params.addParam<FunctionName>("inner_radius", 0., "Inner radius of the heat structure [m]");
  params.addParam<FunctionName>("outer_radius", "Outer radius of the heat structure [m]");

  return params;
}

registerMooseObject("TMAPApp", SphericalStructure);

InputParameters
SphericalStructure::validParams()
{
  params.addRequiredParam<std::vector<Real>>("depths", "Depth of each radial region [m]");
  params.addRequiredParam<std::vector<unsigned int>>("n_radial_elems", "Number of elements in each radial region");
  params.addRequiredParam<std::vector<std::string>>("materials","Material name for each radial region");
  params.addParam<Real>("mult", 1.0, "Structure multiplicity; Number of identical structures represented by this one");
  params.addParam<FunctionName>("initial_T", "Initial temperature [K]");
  // Both of the following optional; omission implies solid sphere.  For spherical shell, at least one required.                                       
  params.addParam<FunctionName>("inner_radius", 0., "Inner radius of the heat structure [m]");
  params.addParam<FunctionName>("outer_radius", "Outer radius of the heat structure [m]");

  return params;
}

@lindsayad
Copy link
Member Author

lindsayad commented Jun 10, 2021

@humrpw the way you've drawn things up here makes me intuitively think of an input file that looks like this:

[Components]
  [f_enc]
    type = FunctionalEnclosure
    volume = 'foo'
    material = 'bar'
    blah blah blah
  []
  [b_enc]
    type = BoundaryEnclosure
    blah blah blah
  []

  [plate]
    type = PlateStructure
    blah blah blah
  []
[]

So that looks like a THM type input file. Alternatively you could have

[Enclosures]
  [f_enc]
    type = FunctionalEnclosure
    blah blah blah
  []
  [b_enc]
    type = BoundaryEnclosure
    blah blah blah
  []
[]

[Structures]
  [plate]
    type = PlateStructure
    blah blah blah
  []
[]

be the outer syntax. Which would you prefer?

@humrpw
Copy link

humrpw commented Jun 15, 2021

First one is good. I'm inclined to adopt THM-like input unless there's a particular reason not to. Plus this option gives flexibility to organize components within an input file in whatever order you like (not enclosures in one block, and structures in another block).

@lindsayad
Copy link
Member Author

Awesome. Option 1 was my preference

@lindsayad
Copy link
Member Author

This will mean we will need THM as a submodule in order for this to work, but I think that's totally fine. I also think @andrsd was considering moving Component syntax straight into MOOSE which would eliminate the dependency

@andrsd
Copy link

andrsd commented Jun 15, 2021

Yes, the THM-like syntax would be better, IMO. Just keep in mind that refactoring the Component layer into a separate module would be a fairly large task. But, very useful, I think...

@humrpw
Copy link

humrpw commented Jul 6, 2021

Flows between enclosures we could handle one of two ways. Since these are always just user specified and therefore require little input, we could just make them part of enclosure blocks as in legacy TMAP:

[Enclosures]
  [f_enc]
    type = FunctionalEnclosure
    blah blah blah
    outflow = 'Enclosure2   3.19'
    outflow = 'Enclosure3   0.07'
  []
[]

This is probably the most compact way to capture this input. But, if desirable or necessary for compatibility with THM, we could make this a separate component:

[Components]
    [Enclosures]
      [f_enc]
        type = FunctionalEnclosure
        blah blah blah
        outflow = 'Enclosure2   3.19'
        outflow = 'Enclosure3   0.07'
      []
      [Enclosure2]
        type = FunctionalEnclosure
        blah blah blah
      []
      [Enclosure3]
        type = FunctionalEnclosure
        blah blah blah
      []
    []
    [Outflows]
      [MainFlow]
        from = 'f_enc'
        to = 'Enclosure2'
        flow_rate = 3.19
      []
      [ToCleanupSys]
        from = 'f_enc'
        to = 'Enclosure3'
        flow_rate = 0.07
      []
    []
[]

@andrsd
Copy link

andrsd commented Jul 7, 2021

This syntax won't work:

  [f_enc]
    type = FunctionalEnclosure
    blah blah blah
    outflow = 'Enclosure2   3.19'
    outflow = 'Enclosure3   0.07'
  []
[]

You cannot specify one parameter multiple times. Also mixing parameter types makes it harder on the coding side - for example error handling, etc.

However, you could do something like this:

outflow_names = 'Enclosure2 Enclosure3'
outflow_values = '3.19 0.07'

Just FYI.

For your second example:

You can do groups like [Enclosures], and [Outflows] - THM supports that, but your second example specifies the same information multiple times. If I understand correctly that you want to connect flow from f_enc to Enclosure2 and Enclosure3, this is the syntax you would want to shoot for:

[Components]
    [f_enc]
      type = FunctionalEnclosure
      blah blah blah
    []
    [Enclosure2]
      type = FunctionalEnclosure
      blah blah blah
    []
    [Enclosure3]
      type = FunctionalEnclosure
      blah blah blah
    []
    [MainFlow]
      type = Outflow
      from = 'f_enc'
      to = 'Enclosure2'
      flow_rate = 3.19
    []
    [ToCleanupSys]
      type = Outflow
      from = 'f_enc'
      to = 'Enclosure3'
      flow_rate = 0.07
    []
[]

Note that if you are specifying a component is has to have a type parameter.

This is what we would do with flow channels and junctions. Actually, we would have just one junction connecting the right ends of f_enc, Enclosure2 and Enclosure3, since our junctions can connect multiple ends. I realize this may not be your case, so I kept 2 outflow components to be consistent with your original setup.

@lindsayad
Copy link
Member Author

Ok @humrpw I've taken the first run at creating Enclosures and Structures. As a first test I've created a Component version of the val-1a test. Here's the MOOSE input version:

[Mesh]
  type = GeneratedMesh
  dim = 1
  nx = 10
  xmax = ${fparse 3.3e-5 * length_unit}
[]

[Kernels]
  [diff]
    type = MatDiffusion
    variable = u
    diffusivity = ${fparse 1.58e-4*exp(-308000/(8.314*top_level_temperature))*length_unit^2}
  []
  [time]
    type = TimeDerivative
    variable = u
  []
[]

[ScalarKernels]
  [time]
    type = ODETimeDerivative
    variable = v
  []
  [flux_sink]
    type = EnclosureSinkScalarKernel
    variable = v
    flux = flux
    surface_area = ${fparse 2.16e-6*length_unit^2}
    volume = ${fparse 5.2e-11*length_unit^3}
    concentration_to_pressure_conversion_factor = ${fparse kb*length_unit^3*top_level_temperature*pressure_unit}
  []
[]

[BCs]
  [left]
    type = EquilibriumBC
    variable = u
    enclosure_scalar_var = v
    boundary = 'left'
    K = ${fparse 7.244e22/(top_level_temperature * length_unit^3 * pressure_unit)}
    temperature = ${top_level_temperature}
  []
[]

[Variables]
  [u]
  []
  [v]
    family = SCALAR
    order = FIRST
    initial_condition = ${fparse initial_pressure*pressure_unit}
  []
[]

[Postprocessors]
  [flux]
    type = SideDiffusiveFluxIntegral
    variable = u
    diffusivity = ${fparse 1.58e-4*exp(-308000/(8.314*top_level_temperature))*length_unit^2}
    boundary = 'left'
    execute_on = 'initial nonlinear linear timestep_end'
    outputs = ''
  []
[]

and then the Component version

[GlobalParams]
  species = 'u'
  length_unit = ${top_level_length_unit}
  temperature = ${top_level_temperature}
[]

[Functions]
  [D_u]
    type = ParsedFunction
    value = '1.58e-4*exp(-308000/(8.314*temperature))'
    vars = 'temperature'
    vals = '${top_level_temperature}'
  []
  [K_u]
    type = ParsedFunction
    value = '7.244e22/temperature'
    vars = 'temperature'
    vals = '${top_level_temperature}'
  []
[]

[Components]
  [structure]
    type = Structure1D
    diffusivities = 'D_u'
    nx = 10
    xmax = 3.3e-5
  []

  [enc]
    type = FunctionalEnclosure0D
    species_initial_pressures = '${initial_pressure}'
    pressure_unit = ${pressure_unit}
    surface_area = 2.16e-6
    volume = 5.2e-11
    equilibrium_constants = 'K_u'
    structure = 'structure'
    boundary = 'left'
  []
[]

What do you think?

@lindsayad
Copy link
Member Author

Notes which @humrpw can edit/add-to:

  • Have coupling between enclosure-structure defined in structure block instead of the other way around
  • In FunctionalEnclosures allow user to specify equilibrium_constant and one of surface_rate_constant or two surface_rate_constants. Or you can allow them to specify all three and check their math
  • Remember to support Implement more fancy flux balances #10

@andrsd
Copy link

andrsd commented Jul 30, 2021

If you would also have a case where structure would be just stand alone, I would recommend you do what we did for flow channel and heat structure. They both can be stand alone and then we have a heat transfer component to couple them together. This design allowed us a lot of flexibility - especially made coupling with multi-apps very simple.

Just an idea...

@lindsayad
Copy link
Member Author

@singhgp4321 initial work done on this branch https://github.com/lindsayad/TMAP8/tree/syntax-8 for component syntax development

cticenhour added a commit to cticenhour/TMAP8 that referenced this issue Sep 13, 2022
@cticenhour cticenhour added the T: Task An enhancement to the software. label Apr 11, 2023
GiudGiud pushed a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
Re-create val-1a test with components
refs idaholab#8
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
…gPhysics live there

Rework 1D structure to use a DiffusionPhysics
refs idaholab#8
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
GiudGiud added a commit to GiudGiud/TMAP8 that referenced this issue Jan 13, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
T: Task An enhancement to the software.
Projects
None yet
Development

No branches or pull requests

4 participants