MESTI.jl icon indicating copy to clipboard operation
MESTI.jl copied to clipboard

mesti_subpixel_smoothing function

Open yggbg opened this issue 10 months ago • 0 comments

Hello, there is an issue inside the mesti_subpixel_smoothing() function at line 148:

if xBC == "periodic" || xBC == "Bloch"
    object_list_temp = deepcopy(object_list)        
    num_new_periodic_object = 0
    for obj_ind = 1:length(object_list)
        object = object_list[obj_ind]
        if bounds(object)[1][1] <= bounds(domain)[1][1] && bounds(object)[2][1] >= bounds(domain)[1][1] && bounds(object)[2][1] < bounds(domain)[2][1]
            insert!(object_list_temp, obj_ind+num_new_periodic_object+1, translate(object, [bounds(domain)[2][1]-bounds(domain)[1][1],0,0]))
            insert!(object_epsilon_list, obj_ind+num_new_periodic_object+1, object_epsilon_list[obj_ind+num_new_periodic_object])
            num_new_periodic_object = num_new_periodic_object + 1
        elseif bounds(object)[1][1] <= bounds(domain)[2][1] && bounds(object)[2][1] >= bounds(domain)[2][1] && bounds(object)[1][1] > bounds(domain)[1][1]
# line below is where the issue occurs
             insert!(object_list_temp,  translate(object, obj_ind+num_new_periodic_object+1, [-(bounds(domain)[2][1]-bounds(domain)[1][1]),0,0]))
            insert!(object_epsilon_list, obj_ind+num_new_periodic_object+1, object_epsilon_list[obj_ind+num_new_periodic_object])                
            num_new_periodic_object = num_new_periodic_object + 1               
        end
    end
    object_list = deepcopy(object_list_temp)
    object_list_temp = nothing
end

After taking a look at this page I realized that there are 3 inputs to the translate() function instead of the expected 2 inputs.

Here's the block of code for the yBC part:

if yBC == "periodic" || yBC == "Bloch"
    object_list_temp = deepcopy(object_list)        
    num_new_periodic_object = 0        
    for obj_ind = 1:length(object_list)
        object = object_list[obj_ind]
        if bounds(object)[1][2] <= bounds(domain)[1][2] && bounds(object)[2][2] >= bounds(domain)[1][2] && bounds(object)[2][2] < bounds(domain)[2][2]
            insert!(object_list_temp, obj_ind+num_new_periodic_object+1, translate(object, [0, bounds(domain)[2][2]-bounds(domain)[1][2], 0]))
            insert!(object_epsilon_list, obj_ind+num_new_periodic_object+1, object_epsilon_list[obj_ind+num_new_periodic_object])                                
            num_new_periodic_object = num_new_periodic_object + 1
        elseif bounds(object)[1][2] <= bounds(domain)[2][2] && bounds(object)[2][2] >= bounds(domain)[2][2] && bounds(object)[1][2] > bounds(domain)[1][2]
# line below is the yBC equivalent of the line above that caused the issue
             insert!(object_list_temp, obj_ind+num_new_periodic_object+1, translate(object, [0, -(bounds(domain)[2][2]-bounds(domain)[1][2]), 0]))
            insert!(object_epsilon_list, obj_ind+num_new_periodic_object+1, object_epsilon_list[obj_ind+num_new_periodic_object])                                
            num_new_periodic_object = num_new_periodic_object + 1               
        end
    end
    object_list = deepcopy(object_list_temp)
    object_list_temp = nothing        
end

Replacing the faulty line with the following fixed the issue on my end:

insert!(object_list_temp, obj_ind+num_new_periodic_object+1, translate(object, [-(bounds(domain)[2][1]-bounds(domain)[1][1]),0,0]))

Thank you!

yggbg avatar Mar 31 '25 20:03 yggbg