Skip to content

Add the ability to build an SSC logic tree at runtime to skip XMLs#11497

Open
CB-quakemodel wants to merge 31 commits into
masterfrom
no_xml
Open

Add the ability to build an SSC logic tree at runtime to skip XMLs#11497
CB-quakemodel wants to merge 31 commits into
masterfrom
no_xml

Conversation

@CB-quakemodel
Copy link
Copy Markdown
Contributor

@CB-quakemodel CB-quakemodel commented May 28, 2026

Here I add a new capability in the form of a class called RuntimeSourceModelLT, which is used to build an SSC LT from a builder script provided by the user in the job file in place of the regular SSC logic tree XML (it still uses the source_model_logic_tree_file key).

The builder script provided by the user must contain a top level function called get_source_model_lt which returns a list of triples of (name, weight, xml_str) where xml_str is just a text representation of the info that would be written to disk in an XML.

The RuntimeSourceModelLT ensures that all the regular checks are performed when constructing the SSC LT (e.g. weights sum to 1).

An example application can be found in qa_test_data/logictree/case_34, which includes a builder script constructing a simple SSC logic tree using this approach. Checks in this QA test ensure that identical results are obtained with both full-enumeration and sampling when using an equivalent SSC logic tree constructed from XMLs. An expected results check is also added for event-based.

There are also unit tests added to ensure other capabilities such as obtaining a composite source model and using to/from hdf5 are supported for RuntimeSourceModelLT.

*** IMPORTANT ***

  1. This initial approach only accepts one branching level (i.e. you cannot apply epistemic uncertainties using additional branching levels, each branch you wish to describe must be represented by an individual XML, so if you want epistemic uncertainty on dip, you need one XML for each dip value).

  2. The BASE183 limit is bypassed here (but realisations are still correctly handled and labelled uniquely). This is because RuntimeSourceModelLT accepts an arbitrary number of branches because it bypasses the XML-based SourceModelLogicTree validation that rejects branchsets larger than 183. The branch_path uniqueness problem that would arise beyond this limit is fixed by switching from a BASE183-indexed shortener to one that maps each branch name to itself, with shorten() updated to use the full name rather than just its first character (a check ensures this is only permitted for RuntimeSourceModelLT and also that each name in the list of triples returned in get_source_model_lt is unique as required.

@CB-quakemodel CB-quakemodel added this to the Engine 3.26.0 milestone May 28, 2026
@CB-quakemodel CB-quakemodel changed the title Add the ability to build an SSC logic tree at runtime to skip XMLs [WIP] Add the ability to build an SSC logic tree at runtime to skip XMLs May 28, 2026
@micheles
Copy link
Copy Markdown
Contributor

Not what I had in mind, but you cannot be a mind reader. The tests are useful, though.

@CB-quakemodel CB-quakemodel changed the title [WIP] Add the ability to build an SSC logic tree at runtime to skip XMLs Add the ability to build an SSC logic tree at runtime to skip XMLs May 28, 2026
Copy link
Copy Markdown
Member

@mmpagani mmpagani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks good to me, and it also gives Michele a bit more time to work on his approach. @micheles, do you prefer to work on this once it's in master or in a branch?

@micheles
Copy link
Copy Markdown
Contributor

No, it cannot be merged as it is. Hopefully, next week I will have some time to spend on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants