Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/SarahIaquinta/adaptative_uptake_of_NPs
24 June 2024, 09:22:23 UTC
  • Code
  • Branches (6)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/dependabot/pip/pillow-9.3.0
    • refs/heads/implement_PCE
    • refs/heads/investigate_PCE
    • refs/heads/main
    • refs/heads/pr_public_repo
    • refs/heads/release
    No releases to show
  • fbdbe95
  • /
  • np_uptake
  • /
  • model
  • /
  • phase_diagrams.py
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:9b0aaac74283d3737cd3554b7412f5ea665bf4e4
origin badgedirectory badge
swh:1:dir:10a418e09680eca59f5f3727921753676797b55f
origin badgerevision badge
swh:1:rev:27b6a958c5d57f02caec72211e0b6c83664e7e08
origin badgesnapshot badge
swh:1:snp:66144eb495e231b19013dc94fc62e65219436b22

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 27b6a958c5d57f02caec72211e0b6c83664e7e08 authored by Sarah Iaquinta on 24 June 2024, 06:06:49 UTC
Merge pull request #3 from anciaux/main
Tip revision: 27b6a95
phase_diagrams.py

import seaborn as sns
import numpy as np
import itertools
import np_uptake.model.cellular_uptake_rigid_particle as cellupt
import np_uptake.figures.utils as fiu
import np_uptake.model.system_definition as sysdef
import tikzplotlib
from np_uptake.figures.utils import tikzplotlib_fix_ncols
from pathlib import Path

def generate_phase_diagram_dataset(args, r_bar):
    particle = sysdef.ParticleGeometry(r_bar=r_bar, particle_perimeter=args.particle_perimeter, sampling_points_circle=300)
    membrane = sysdef.MembraneGeometry(particle, sampling_points_membrane=100)
    wrapping = sysdef.Wrapping(wrapping_list=np.arange(0.03, 0.97, 0.003125))
    energy_computation = cellupt.EnergyComputation()
    gamma_bar_0_list = np.arange(1, 8.5, 0.5)
    sigma_bar_0_list = np.arange(0.5, 5.75, 0.25)
    generator = list(
    itertools.product(
        gamma_bar_0_list,
        sigma_bar_0_list)
)
    f = open('data_for_phase_diagram_'+ str(r_bar) +  '.txt', "w")
    f.write("r_bar \t gA \t gD \t gS \t sigma_bar_0 \t gamma_bar_0 \t phase\n")
    for i in range(len(generator)):
        tuple = generator[i]
        gamma_bar_0, sigma_bar_0 = tuple
        mechanics = sysdef.MechanicalProperties_Adaptation(
            testcase="testcase",
            gamma_bar_r=args.gamma_bar_r,
            gamma_bar_fs=args.gamma_bar_fs,
            gamma_bar_lambda=args.gamma_bar_lambda,
            gamma_bar_0=gamma_bar_0,
            sigma_bar=sigma_bar_0,
        )
        f_eq, wrapping_phase_number, wrapping_phase, energy_list, time_list = cellupt.identify_wrapping_phase(
            particle, mechanics, membrane, wrapping, energy_computation
        )
        f.write(str(args.r_bar) +"\t" + str(args.gamma_bar_r) +"\t" + str(args.gamma_bar_fs) + "\t" + str(args.gamma_bar_lambda) + "\t" + str(sigma_bar_0) +"\t" + str(gamma_bar_0) + "\t" + str(wrapping_phase_number) + "\n")

def read_data_for_phasediagram_from_datafile(filename):
    with open(filename) as f:
        next(f)
        # line = f.readline()
        gamma_bar_0_list_phase1 = []
        gamma_bar_0_list_phase2 = []
        gamma_bar_0_list_phase3 = []
        sigma_bar_0_list_phase1 = []
        sigma_bar_0_list_phase2 = []
        sigma_bar_0_list_phase3 = [] 
        for line in f:
            values = line.split()
            [r_bar, gamma_bar_r, gamma_bar_fs, gamma_bar_lambda, sigma_bar_0, gamma_bar_0, phase] = [float(s) for s in values]
            if phase == 1:
                gamma_bar_0_list_phase1.append(gamma_bar_0)
                sigma_bar_0_list_phase1.append(sigma_bar_0)
            elif phase == 2:
                gamma_bar_0_list_phase2.append(gamma_bar_0)
                sigma_bar_0_list_phase2.append(sigma_bar_0)
            elif phase == 3:
                gamma_bar_0_list_phase3.append(gamma_bar_0)
                sigma_bar_0_list_phase3.append(sigma_bar_0)
    return gamma_bar_0_list_phase1, gamma_bar_0_list_phase2, gamma_bar_0_list_phase3, sigma_bar_0_list_phase1, sigma_bar_0_list_phase2, sigma_bar_0_list_phase3

def plot_phase_diagram(filename, createfigure, fonts, xticks, xticklabels, savefigure):
    gamma_bar_0_list_phase1, gamma_bar_0_list_phase2, gamma_bar_0_list_phase3, sigma_bar_0_list_phase1, sigma_bar_0_list_phase2, sigma_bar_0_list_phase3 = read_data_for_phasediagram_from_datafile(filename)
    fig = createfigure.square_figure_7(pixels=360)
    ax = fig.gca()
    paired_palette = sns.color_palette("Paired")
    
    ax.plot(
        sigma_bar_0_list_phase1,
        gamma_bar_0_list_phase1,
        "o",
        markersize=5,
        color=paired_palette[8],
        label=r"no wrapping",
    )
    ax.plot(
        sigma_bar_0_list_phase2,
        gamma_bar_0_list_phase2,
        "o",
        markersize=5,
        color=paired_palette[6],
        label=r"partial wrapping",
    )
    ax.plot(
        sigma_bar_0_list_phase3,
        gamma_bar_0_list_phase3,
        "o",
        markersize=5,
        color=paired_palette[2],
        label=r"full wrapping",
    )    
    ax.set_xticks([0.5, 1, 1.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5])
    ax.set_xticklabels(
        ["0.5", "1", "1.5", "1", "1.5", "2", "2.5", "3", "3.5", "4", "4.5", "5", "5.5"],
        font=fonts.serif(),
        fontsize=fonts.axis_legend_size(),
    )
    ax.set_yticks([1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8])
    ax.set_yticklabels(
        ["1", "1.5", "2", "2.5", "3", "3.5", "4", "4.5", "5", "5.5", "6", "6.5", "7", "7.5", "8"],
        font=fonts.serif(),
        fontsize=fonts.axis_legend_size(),
    )
    ax.set_xlabel(r"$\overline{\sigma}$ [ - ]", font=fonts.serif(), fontsize=fonts.axis_label_size())
    ax.set_ylabel(r"$\overline{\gamma}_0$ [ - ]", font=fonts.serif(), fontsize=fonts.axis_label_size())
    ax.legend(prop=fonts.serif(), loc="upper right", framealpha=0.9)
    savefigure.save_as_png(fig, "phasediagram")    
    tikzplotlib_fix_ncols(fig)
    current_path = Path.cwd()
    tikzplotlib.save(current_path/"phasediagram.tex")
        
if __name__ == "__main__":
    args = cellupt.parse_arguments()
    createfigure = fiu.CreateFigure()
    fonts = fiu.Fonts()
    savefigure = fiu.SaveFigure()
    xticks = fiu.XTicks()
    xticklabels = fiu.XTickLabels()
    r_bar=1
    # generate_phase_diagram_dataset(args, r_bar)
    datafile_for_phase_diagram = "data_for_phase_diagram_" + str(r_bar) + ".txt"
    plot_phase_diagram(datafile_for_phase_diagram, createfigure, fonts, xticks, xticklabels, savefigure)

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API