Git Product home page Git Product logo

Comments (12)

drbergman avatar drbergman commented on August 16, 2024

As an example of unexpected behavior:

The implementation of update_dirichlet_node, which seems meant for being the simplest way of setting a DC for a single substrate at a single voxel, can lead to unexpected behavior. To see this, make the template project. Add DCs to substrate with value 38. Then, add a second substrate with DCs off. Finally, use the following in custom.cpp for setup_microenvironment and run.

void setup_microenvironment( void )
{
    initialize_microenvironment();
    microenvironment.update_dirichlet_node( 175 , 1 , 1 ); // note that this supposedly leaves "substrate" (with index 0) alone
    return; 
}

the first substrate will end up with a DC of value 0 also at voxel 175:
image

from physicell.

MathCancer avatar MathCancer commented on August 16, 2024

HI, I wanted to touch base with you. Is this still unresolved?

from physicell.

drbergman avatar drbergman commented on August 16, 2024

Yeah, it still is unresolved when using the latest PhysiCell release.

from physicell.

MathCancer avatar MathCancer commented on August 16, 2024

Thanks, Daniel. Sorry I didn't see the response.

Maybe we should have a quick call about it in the next week or so, so we can examine and plan expected behavior for a fix in 1.11.1.

It might be a bug, or could be poor documentation, so I'd like to work it super carefully. Thank you!

from physicell.

drbergman avatar drbergman commented on August 16, 2024

That would work for me!

from physicell.

rheiland avatar rheiland commented on August 16, 2024

I created a unit test of sorts which seems to do what I expect. If nothing else, we have a concrete test for reference. I will likely do a PR to PhysiCell dev eventually; never too many tests. Rf the Readme.txt, the custom.cpp setup_microenvironment, and the 2 .png images.
https://github.com/rheiland/PhysiCell/tree/development/unit_tests/custom_DCs_2substrates

from physicell.

rheiland avatar rheiland commented on August 16, 2024

And I just created a custom_v2.cpp which is more similar to your example in that it only changes a single (center) voxel value of just one substrate (oxygen) and leaves the other alone. See the updated files and Readme.txt. I also fixed the config file so the PMB/Studio (v2.19.2) would be happy. See *v2.png files too.

from physicell.

rheiland avatar rheiland commented on August 16, 2024

To more closely mimic Daniel's original test, I committed a new config file with the glucose BCs=99:

        <variable name="glucose" units="dimensionless" ID="1">
            <physical_parameter_set>
                <diffusion_coefficient units="micron^2/min">0</diffusion_coefficient>
                <decay_rate units="1/min">0</decay_rate>
            </physical_parameter_set>
            <initial_condition units="particles/micron^3">0</initial_condition>
            <Dirichlet_boundary_condition units="particles/micron^3" enabled="True">99</Dirichlet_boundary_condition>
            <Dirichlet_options>
                <boundary_value ID="xmin" enabled="True">99</boundary_value>
                <boundary_value ID="xmax" enabled="True">99</boundary_value>
                <boundary_value ID="ymin" enabled="True">99</boundary_value>
                <boundary_value ID="ymax" enabled="True">99</boundary_value>
                <boundary_value ID="zmin" enabled="False">0</boundary_value>
                <boundary_value ID="zmax" enabled="False">0</boundary_value>
            </Dirichlet_options>
        </variable>

Running the test using the simpler custom_v2.cpp where we only do:

void setup_microenvironment( void )
{
	initialize_microenvironment(); 	

    int idx_oxygen = 0;  // just hard-coded; better to get index by name.
    double oxy_value = 40.0;
    microenvironment.update_dirichlet_node( 4, idx_oxygen, oxy_value);
}

it seems like we still have the expected results? Perhaps I'm still missing something though. See https://github.com/rheiland/PhysiCell/blob/development/unit_tests/custom_DCs_2substrates/oxygen_v2.png and https://github.com/rheiland/PhysiCell/blob/development/unit_tests/custom_DCs_2substrates/glucose_v2.png

from physicell.

rheiland avatar rheiland commented on August 16, 2024

I finally got back to this and think I've fixed the bug, taking an approach that Paul agreed with, whereby we assume DC activation is false everywhere (instead of true, as it was previously), then just set it true when needed.

Please test if you get a chance, from this branch: https://github.com/MathCancer/PhysiCell/tree/dev-randy-DCs

  • see diffs in BioFVM_microenvironment.h and .cpp
    • changed true to false in many places
    • added a new method get_substrate_dirichlet_value
    • commented out a loop at the very end setting activation vectors (rf. April 2023 comment)
  • see unit_tests/custom_DCs_2substrates (and Readme.txt there)

Not sure if we also want to fix a method with confusing args, rf. TODO? fix confusing swapped usage of args comment in BioFVM_microenvironment.cpp

from physicell.

rheiland avatar rheiland commented on August 16, 2024

I just pushed this same fix into my (rheiland) fork (dev branch) for 1.12.0 (https://github.com/rheiland/PhysiCell/tree/development) and will do a PR into the MathCancer dev branch after some more testing. Please feel free to test your use case(s). I created a new, very simple one which also illustrated the bug before the fix:

  • create 2 substrates: subA and subB
  • specify DC only on xmax boundary of subA
  • specify DC only on ymax boundary of subB
  • run and plot results

Bug: Both DCs on both boundaries appear on both substrates.

from physicell.

MathCancer avatar MathCancer commented on August 16, 2024

Hello!
Do we feel this is now resolved in 1.13.0?
Thanks for your great work on this!

from physicell.

drbergman avatar drbergman commented on August 16, 2024

Yes! I believe it is resolved!

from physicell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.