[Scons-users] SCons for Ansys APDL Analysis

Hubley, Christopher (GE Aerospace, US) Christopher.Hubley at ge.com
Mon Oct 17 14:02:47 EDT 2022


> -----Original Message (Truncated)-----
> From: Scons-users <scons-users-bounces at scons.org> On Behalf Of Mats Wichmann
> Sent: Monday, October 17, 2022 12:28 PM
> To: scons-users at scons.org
> Subject: EXT: Re: [Scons-users] SCons for Ansys APDL Analysis
> 
> On 10/17/22 08:33, Hubley, Christopher (GE Aerospace, US) wrote:
> > Hello,
> > I've been researching the use of SCons for engineering analysis with Ansys
> > Parametric Design Language (APDL).
> > 
> > ... 
> > 
> > "Dependencies 1"                "Dependencies 2"
> >      |                              |
> >      |              +--Some files-->+              +--Some files-->+
> >      |              |               |              |
> >      v              |               v              |
> > "Compile 1" --> "Results 1"     "Compile 2" --> "Results 2" ... and so on a hundred more times
> > 
> > (this diagram will only be readable if you use a monospace font)
> > 
> > ...
> >
> > What I'd like to do is run/build my each load step in a target directory,
> > and then remove the dependencies from the build directory. I'm hoping SCons
> > could decide whether to run a load step based on whether the input files
> > have been updated.
> > 
> > ...
> 
> People have tried to do all sorts of interesting things with SCons, you 
> might glance at this posting:
> 
> http://zacharytessler.com/2015/03/05/data-workflows-with-scons/
> 
> It would take more time to wrap the brain around what you're really 
> asking... SCons is good at computing changes in the dependency tree 
> between runs, but not as good at changes that may happen during a run. 
> Yes, it can handle cases where a derived file (target) is also the 
> source for another target but you do need to keep in mind that the 
> workflow is pretty explicitly multi-phase: (1) read the build 
> configuration (SConscripts) and build up the dependency graph, (2) 
> compute what needs to be (re)built based on that graph. If you try to 
> cross that line between (1) and (2) - aka doing things in the build that 
> changes the graph - that's not going to work well.

Thanks for following up. I'm a bit worried about the workflow that I was able
to get working, which involves having separate SConscript files for each load
step. That might not be so manageable for 100+ load steps.  But, I think that I
may be able to have a single SConscript file and dump all of the results into
a single variant directory.

I've got a couple of goals:

* Generate results in a separate directory from source code
  (I think that this requires copying the source into target directory and
   removing it after compiling)
* Re-run load steps ('recompile') only if the inputs are changed
* Process ANSYS outputs with another internal company tool if they are changed

Long term, it'd be great if we could use SCons (or something similar) to string
together a bunch of separate analysis tools that we use. Thus, if there were a
change to an engine cycle analysis, a thermal analysis, a geometric feature/stress
analysis, fatigue life analysis, etc., we could re-populate our whole chain of
analyses.


Christopher K. Hubley
Senior Engineer, TFTJ Fan & Compressor
GE Aviation



-----Original Message-----
From: Scons-users <scons-users-bounces at scons.org> On Behalf Of Mats Wichmann
Sent: Monday, October 17, 2022 12:28 PM
To: scons-users at scons.org
Subject: EXT: Re: [Scons-users] SCons for Ansys APDL Analysis

WARNING: This email originated from outside of GE. Please validate the sender's email address before clicking on links or attachments as they may not be safe.

On 10/17/22 08:33, Hubley, Christopher (GE Aerospace, US) wrote:
> Hello,
> I've been researching the use of SCons for engineering analysis with Ansys Parametric Design Language (APDL).
> 
> APDL is a Fortran-like scripting language, used for performing finite element analysis with the Ansys software.
> 
> We typically generate analyses written in APDL which have complex sets of dependencies, and I'm hoping SCons will be able to help manage those.
> 
> "Dependencies 1"                "Dependencies 2"
>      |                              |
>      |              +--Some files-->+              +--Some files-->+
>      |              |               |              |
>      v              |               v              |
> "Compile 1" --> "Results 1"     "Compile 2" --> "Results 2" ... and so on a hundred more times
> 
> (this diagram will only be readable if you use a monospace font)
> 
> It's not uncommon to edit dependencies for a load step ("compile") in the middle of a long analysis. It'd be great if we had a build tool which could detect changes to inputs and only compile load steps which have changed.
> 
> I've managed to write a Builder using the Command() function, and it seems to work... but only just so.
> 
> I find it difficult to share the output from one build as an input to the next build. Part of the problem might be that I'm new to the software and I've had a hard time wrapping my head around what Scons is doing under the hood for file management.
> 
> What I'd like to do is run/build my each load step in a target directory, and then remove the dependencies from the build directory. I'm hoping SCons could decide whether to run a load step based on whether the input files have been updated.

People have tried to do all sorts of interesting things with SCons, you 
might glance at this posting:

http://zacharytessler.com/2015/03/05/data-workflows-with-scons/

It would take more time to wrap the brain around what you're really 
asking... SCons is good at computing changes in the dependency tree 
between runs, but not as good at changes that may happen during a run. 
Yes, it can handle cases where a derived file (target) is also the 
source for another target but you do need to keep in mind that the 
workflow is pretty explicitly multi-phase: (1) read the build 
configuration (SConscripts) and build up the dependency graph, (2) 
compute what needs to be (re)built based on that graph. If you try to 
cross that line between (1) and (2) - aka doing things in the build that 
changes the graph - that's not going to work well.




> 
> Here's an example of what I think the SCons scripts might look like:
> 
> # SConstruct
> from site_scons import run_ansys
> 
> ansys_version = '19.2'
> 
> env = Environment(tools=['mingw'])
> env.Decider('timestamp-newer')
> env.AddMethod(ansys_runner, 'Ansys')
> 
> 
> # Frictionless Assembly
> assy_mu0_dir = Path('results/assembly_mu0').resolve()
> SConscript(
>      'analysis/assembly_mu0/SConscript',
>      variant_dir = str(assy_mu0_dir),
>      duplicate = True,
>      exports = ['env', 'assy_mu0_dir', 'ansys_version'],
> )
> # Import linked dependencies
> env.Import('assy_mu0_restart')
> 
> 
> # Frictional Assembly (restart from frictionless) assy_dir = Path('results/assembly').resolve()
> SConscript(
>      'analysis/assembly/SConscript',
>      variant_dir = str(assy_dir),
>      duplicate = True,
>      exports = ['env', 'ansys_version', 'assy_dir', 'assy_mu0_restart'],
> )
> 
> .
> .
> .
> 
> # analysis/assembly/SConscript (example of SConscript)
> from pathlib import Path
> 
> Import('env', 'ansys_version', 'assy_dir', 'assy_mu0_restart')
> 
> assy = 'HPC_2D_ASSY'
> assy_restart = tuple(
>      str(assy_mu0_dir / f'{assy}.{ext}')
>      for ext in ('db', 'emat', 'esav')
> )
> env.Ansys(
>      input_file = 'assy.inp',
>      output_files = (*assy_restart, f'{assy}.out'),
>      jobname = assy,
>      restart_files = assy_mu0_restart,
>      ansys_version = ansys_version,
> )
> env.Export('assy_restart')
> 
> 
> I suppose that my question is whether anyone has done this kind of thing with SCons before?
> And is the tool appropriate for that? Or am I just trying to push a rope?
> 
> As I started laying it out, it seemed like I was writing a lot more code than I was anticipating to get it working.
> 
> If this has been done before... are there any examples out in the world which I might be able to leverage?
> 
> 
> Christopher K. Hubley
> Senior Engineer, TFTJ Fan & Compressor
> GE Aviation
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users

_______________________________________________
Scons-users mailing list
Scons-users at scons.org
https://pairlist4.pair.net/mailman/listinfo/scons-users


More information about the Scons-users mailing list