Skip to content

Commit

Permalink
[FTheoryTools] Small QOL changes (#3911)
Browse files Browse the repository at this point in the history
[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.
  • Loading branch information
emikelsons authored Jul 4, 2024
1 parent ae8c86b commit c629918
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"model_index": "13",
"model_index": "45",
"arxiv_data": {
"id": "1903.00009",
"doi": "10.48550/arXiv.1903.00009",
Expand Down
48 changes: 47 additions & 1 deletion experimental/FTheoryTools/src/LiteratureModels/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,54 @@ end
# 6. Function to display all known literature models
#######################################################

function display_all_literature_models()
@doc raw"""
display_all_literature_models(model_fields::Dict{String,<:Any} = Dict{String,Any}())
Displays all literature models that satisfy the model_fields criteria. The fields currently supported are those occuring in index.json.
```jldoctest
julia> display_all_literature_models(Dict("gauge_algebra" => ["u(1)", "su(2)", "su(3)"]))
Model 33:
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")
Model 34:
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")
Model 39:
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")
Model 40:
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")
Model 45:
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")
julia> display_all_literature_models(Dict("gauge_algebra" => "e"))
Model 8:
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")
Model 9:
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")
Model 10:
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")
```
"""
function display_all_literature_models(model_fields::Dict{String,<:Any} = Dict{String,Any}())
file_index = JSON.parsefile(joinpath(@__DIR__, "index.json"))
@req issubset(keys(model_fields), keys(file_index[1])) "The inputted criteria aren't supported"
for field in keys(model_fields)
if field == "gauge_algebra"
for s in model_fields["gauge_algebra"]
filter!(x -> occursin(s, join(x["gauge_algebra"])), file_index)
end
else
filter!(x -> x[field] == model_fields[field], file_index)
end
end
if length(file_index) == 0
println("No such models found in database")
end
sorted_dicts = sort(file_index, by = x -> parse(Int, x["model_index"]))
for dict in sorted_dicts
print("Model $(dict["model_index"]):\n")
Expand Down
28 changes: 22 additions & 6 deletions experimental/FTheoryTools/src/LiteratureModels/create_index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ function _create_literature_model_index()
filter!(s -> startswith(s, "model"), models)

index = Vector{Dict{String,Union{String,Vector{Any}}}}()
model_indices = JSON.parsefile(joinpath(@__DIR__, "model_indices.json"))
for model in models
model_data = JSON.parsefile(model_directory * model)

model_index_dict = Dict("model_index" => get(model_data, "model_index", ""))
model_index = get(model_indices, model, "")
if model_index == ""
model_index = string.(maximum([parse(Int, x) for x in collect(values(model_indices))]) + 1)
model_indices[model] = model_index
end

model_index_dict = Dict("model_index" => model_index)

arxiv_data = get(model_data, "arxiv_data", false)
if arxiv_data != false
Expand Down Expand Up @@ -65,20 +71,30 @@ function _create_literature_model_index()

model_descriptor_data = get(model_data, "model_descriptors", false)
if model_descriptor_data != false
model_descriptor_data_dict = Dict("type" => get(model_descriptor_data, "type", [""]))
model_descriptor_data_dict = Dict("type" => get(model_descriptor_data, "type", [""]), "gauge_algebra" => get(model_descriptor_data, "gauge_algebra", [""]))
else
model_descriptor_data_dict = Dict{String,Union{String,Vector{Any}}}()
end



index_entry = merge(model_index_dict, arxiv_dict, journal_dict, meta_data_dict, model_descriptor_data_dict)
index_entry["file"] = model
if !isempty(index_entry)
push!(index, index_entry)
end
end


#Check if any models have been removed and update the index accordingly
if issetequal(collect(keys(model_indices)), models) == false
difference = setdiff(collect(keys(model_indices)), models)
for key in difference
delete!(model_indices, key)
end
end

open(joinpath(@__DIR__,"index.json"), "w") do file
JSON.print(file, index)
end
open(joinpath(@__DIR__,"model_indices.json"), "w") do file
JSON.print(file, sort(model_indices), 2)
end
end
Loading

0 comments on commit c629918

Please sign in to comment.