Skip to content

Commit c629918

Browse files
authored
[FTheoryTools] Small QOL changes (#3911)
[FTheoryTools] Small QOL changes Expanded display_all_literature_models() so that now it's possible to filter for models with desired properties(gauge algebra etc.). Made new file model_indices.json that keeps track of a model's index. Running _create_literature_model_index() updates this file. * Added a check for removed models If a model is removed, then the corresponding index is also removed from model_indices.json . Currently this index isn't freed up unless the removed model is the latest one, but since this won't happen often if ever, this really just functions as an additonal test, whenever a new model is added.
1 parent ae8c86b commit c629918

File tree

5 files changed

+118
-9
lines changed

5 files changed

+118
-9
lines changed

experimental/FTheoryTools/src/LiteratureModels/Models/model1903.00009.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"model_index": "13",
2+
"model_index": "45",
33
"arxiv_data": {
44
"id": "1903.00009",
55
"doi": "10.48550/arXiv.1903.00009",

experimental/FTheoryTools/src/LiteratureModels/constructors.jl

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,54 @@ end
606606
# 6. Function to display all known literature models
607607
#######################################################
608608

609-
function display_all_literature_models()
609+
@doc raw"""
610+
display_all_literature_models(model_fields::Dict{String,<:Any} = Dict{String,Any}())
611+
612+
Displays all literature models that satisfy the model_fields criteria. The fields currently supported are those occuring in index.json.
613+
614+
```jldoctest
615+
julia> display_all_literature_models(Dict("gauge_algebra" => ["u(1)", "su(2)", "su(3)"]))
616+
Model 33:
617+
Dict{String, Any}("journal_section" => "3", "arxiv_page" => "67", "arxiv_id" => "1408.4808", "gauge_algebra" => Any["su(3)", "su(2)", "u(1)"], "arxiv_version" => "2", "journal_equation" => "3.141", "journal_page" => "67", "arxiv_equation" => "3.142", "journal_doi" => "10.1007/JHEP01(2015)142", "arxiv_section" => "3", "journal" => "JHEP", "file" => "model1408_4808-11-WSF.json", "arxiv_doi" => "10.48550/arXiv.1408.4808", "model_index" => "33", "type" => "weierstrass")
618+
619+
Model 34:
620+
Dict{String, Any}("journal_section" => "3", "arxiv_page" => "67", "arxiv_id" => "1408.4808", "gauge_algebra" => Any["su(3)", "su(2)", "u(1)"], "arxiv_version" => "2", "journal_equation" => "3.141", "journal_page" => "67", "arxiv_equation" => "3.142", "journal_doi" => "10.1007/JHEP01(2015)142", "arxiv_section" => "3", "journal" => "JHEP", "file" => "model1408_4808-11.json", "arxiv_doi" => "10.48550/arXiv.1408.4808", "model_index" => "34", "type" => "hypersurface")
621+
622+
Model 39:
623+
Dict{String, Any}("journal_section" => "3", "arxiv_page" => "75", "arxiv_id" => "1408.4808", "gauge_algebra" => Any["su(3)", "su(2)", "su(2)", "u(1)"], "arxiv_version" => "2", "journal_equation" => "3.167", "journal_page" => "75", "arxiv_equation" => "3.168", "journal_doi" => "10.1007/JHEP01(2015)142", "arxiv_section" => "3", "journal" => "JHEP", "file" => "model1408_4808-14-WSF.json", "arxiv_doi" => "10.48550/arXiv.1408.4808", "model_index" => "39", "type" => "weierstrass")
624+
625+
Model 40:
626+
Dict{String, Any}("journal_section" => "3", "arxiv_page" => "75", "arxiv_id" => "1408.4808", "gauge_algebra" => Any["su(3)", "su(2)", "su(2)", "u(1)"], "arxiv_version" => "2", "journal_equation" => "3.167", "journal_page" => "75", "arxiv_equation" => "3.168", "journal_doi" => "10.1007/JHEP01(2015)142", "arxiv_section" => "3", "journal" => "JHEP", "file" => "model1408_4808-14.json", "arxiv_doi" => "10.48550/arXiv.1408.4808", "model_index" => "40", "type" => "hypersurface")
627+
628+
Model 45:
629+
Dict{String, Any}("journal_section" => "", "arxiv_page" => "2", "arxiv_id" => "1903.00009", "gauge_algebra" => Any["su(3)", "su(2)", "u(1)"], "arxiv_version" => "3", "journal_equation" => "2", "journal_page" => "2", "arxiv_equation" => "2", "journal_doi" => "10.1103/PhysRevLett.123.101601", "arxiv_section" => "II", "journal" => "Physical Review Letters", "file" => "model1903.00009.json", "arxiv_doi" => "10.48550/arXiv.1903.00009", "model_index" => "45", "type" => "hypersurface")
630+
631+
julia> display_all_literature_models(Dict("gauge_algebra" => "e"))
632+
Model 8:
633+
Dict{String, Any}("journal_section" => "", "arxiv_page" => "49", "arxiv_id" => "1212.2949", "gauge_algebra" => Any["e(6)"], "arxiv_version" => "2", "journal_equation" => "", "journal_page" => "", "arxiv_equation" => "5.1", "journal_doi" => "10.1007/JHEP04(2013)061", "arxiv_section" => "5.1", "journal" => "JHEP", "file" => "model1212_2949-5.json", "arxiv_doi" => "10.48550/arXiv.1212.2949", "model_index" => "8", "type" => "tate")
634+
635+
Model 9:
636+
Dict{String, Any}("journal_section" => "", "arxiv_page" => "49", "arxiv_id" => "1212.2949", "gauge_algebra" => Any["e(7)"], "arxiv_version" => "2", "journal_equation" => "", "journal_page" => "", "arxiv_equation" => "5.7", "journal_doi" => "10.1007/JHEP04(2013)061", "arxiv_section" => "5.1", "journal" => "JHEP", "file" => "model1212_2949-6.json", "arxiv_doi" => "10.48550/arXiv.1212.2949", "model_index" => "9", "type" => "tate")
637+
638+
Model 10:
639+
Dict{String, Any}("journal_section" => "", "arxiv_page" => "49", "arxiv_id" => "1212.2949", "gauge_algebra" => Any["e(8)"], "arxiv_version" => "2", "journal_equation" => "", "journal_page" => "", "arxiv_equation" => "5.13", "journal_doi" => "10.1007/JHEP04(2013)061", "arxiv_section" => "5.1", "journal" => "JHEP", "file" => "model1212_2949-7.json", "arxiv_doi" => "10.48550/arXiv.1212.2949", "model_index" => "10", "type" => "tate")
640+
```
641+
"""
642+
function display_all_literature_models(model_fields::Dict{String,<:Any} = Dict{String,Any}())
610643
file_index = JSON.parsefile(joinpath(@__DIR__, "index.json"))
644+
@req issubset(keys(model_fields), keys(file_index[1])) "The inputted criteria aren't supported"
645+
for field in keys(model_fields)
646+
if field == "gauge_algebra"
647+
for s in model_fields["gauge_algebra"]
648+
filter!(x -> occursin(s, join(x["gauge_algebra"])), file_index)
649+
end
650+
else
651+
filter!(x -> x[field] == model_fields[field], file_index)
652+
end
653+
end
654+
if length(file_index) == 0
655+
println("No such models found in database")
656+
end
611657
sorted_dicts = sort(file_index, by = x -> parse(Int, x["model_index"]))
612658
for dict in sorted_dicts
613659
print("Model $(dict["model_index"]):\n")

experimental/FTheoryTools/src/LiteratureModels/create_index.jl

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ function _create_literature_model_index()
2626
filter!(s -> startswith(s, "model"), models)
2727

2828
index = Vector{Dict{String,Union{String,Vector{Any}}}}()
29+
model_indices = JSON.parsefile(joinpath(@__DIR__, "model_indices.json"))
2930
for model in models
3031
model_data = JSON.parsefile(model_directory * model)
31-
32-
model_index_dict = Dict("model_index" => get(model_data, "model_index", ""))
32+
model_index = get(model_indices, model, "")
33+
if model_index == ""
34+
model_index = string.(maximum([parse(Int, x) for x in collect(values(model_indices))]) + 1)
35+
model_indices[model] = model_index
36+
end
37+
38+
model_index_dict = Dict("model_index" => model_index)
3339

3440
arxiv_data = get(model_data, "arxiv_data", false)
3541
if arxiv_data != false
@@ -65,20 +71,30 @@ function _create_literature_model_index()
6571

6672
model_descriptor_data = get(model_data, "model_descriptors", false)
6773
if model_descriptor_data != false
68-
model_descriptor_data_dict = Dict("type" => get(model_descriptor_data, "type", [""]))
74+
model_descriptor_data_dict = Dict("type" => get(model_descriptor_data, "type", [""]), "gauge_algebra" => get(model_descriptor_data, "gauge_algebra", [""]))
6975
else
7076
model_descriptor_data_dict = Dict{String,Union{String,Vector{Any}}}()
7177
end
72-
73-
78+
7479
index_entry = merge(model_index_dict, arxiv_dict, journal_dict, meta_data_dict, model_descriptor_data_dict)
7580
index_entry["file"] = model
7681
if !isempty(index_entry)
7782
push!(index, index_entry)
7883
end
7984
end
80-
85+
86+
#Check if any models have been removed and update the index accordingly
87+
if issetequal(collect(keys(model_indices)), models) == false
88+
difference = setdiff(collect(keys(model_indices)), models)
89+
for key in difference
90+
delete!(model_indices, key)
91+
end
92+
end
93+
8194
open(joinpath(@__DIR__,"index.json"), "w") do file
8295
JSON.print(file, index)
8396
end
97+
open(joinpath(@__DIR__,"model_indices.json"), "w") do file
98+
JSON.print(file, sort(model_indices), 2)
99+
end
84100
end

0 commit comments

Comments
 (0)