First time here? Checkout the FAQ!
x
0 votes
by (250 points)
edited by

Hi ,  I was going through  the example titled , Concept: regions vs. gradients (https://opencarp.org/documentation/examples/02_ep_tissue/05a_regions_vs_gradients).  The example has been very well explained and i have been able to run the file too but what i really want to implement is a gradient of conductivities instead of a gradient of ionic cellular parameters (I want to prescribe a gradient of conductivity instead of regions of conductivities). 

 An earlier question was posted an year ago on almost a similar query. Since the previous question is almost an year old and now there is a relevant example available as well... i thought i should reconfirm if this functionality has been made available now. 

Can you please offer some guidance on how can i do it ? (or if that is even possible in the current openCARP functionality or not ). My end goal is to add a conductance gradient in only a patch (or a region ) of a rectangular or cube tissue geometry. Rest of the tissue sample can have a fixed conductivity. 

I would be thankful for your kind guidance/response.

Best Regards,
Ovais

1 Answer

0 votes
by (570 points)

I guess you are refering to this question.

In the question above, Aurel refers to the `-gi_scale_vec` and `-ge_scale_vec` that are vectors of the size of the number of elements and scale the intra- and extra-cellular conductivities respectively.

You can create such a vector using a similar approach to the example 05a_regions_vs_gradients/. The only difference is that instead of a vector of size of number of points it needs to be a vector of the number of elements.

The following code can be used as a guidance generate a conductivity scaling vector where the conductivity decreases along the x-axis of the generated block:

    size=(20, 0.5, 0.5)
    geom = mesh.Block(size= size)

    # Set fibre angle to 0°, sheet angle to 90° both on "endo" and "epi" surfaces
    geom.set_fibres(0, 0, 90, 90)
    
    # Generate and return base name
    meshname = mesh.generate(geom)

    fmin, fmax = (2, 0)
    adjf_conductivity_fn = job.ID + '_GradientWise_{0:4.2f}-{1:4.2f}_Conductivity.adj'.format(fmin, fmax)
    adjf_conductivity = open(adjf_conductivity_fn, 'w')

    elem, tags, nelems = txt.read(meshname + '.elem')
    points, npts = txt.read(meshname + '.pts')

    um_to_mm = 1e-3
    for i in range(nelems):
        x, y, z = (0,0,0)
        count = 0
        for point in elem[i]:
            x += points[point,0]
            y += points[point,1]
            z += points[point,2]
            count += 1

        x = x/count
        y = y/count
        z = z/count

        scaling = (x*um_to_mm + size[0]/2)/(size[0])*(fmax - fmin) + fmin
        adjf_conductivity.write(f'{scaling}\n')

    adjf_conductivity.close()


    cmd += ['-ge_scale_vec', adjf_conductivity_fn]
    cmd += ['-gi_scale_vec', adjf_conductivity_fn]



by (250 points)
Thanks for your prompt and elaborate reply. Indeed very helpful.

Best Regards
Welcome to openCARP Q&A. Ask questions and receive answers from other members of the community. For best support, please use appropriate TAGS!
architecture, carputils, documentation, experiments, installation-containers-packages, limpet, slimfem, website, governance
...