CenterForTheBuiltEnvironment / comfort-dash

Revision of the CBE Comfort Tool using Dash.
0 stars 12 forks source link

Callback: listening to input changes in real time instead of clicking on the form #32

Closed Jinjia-Bai closed 1 week ago

Jinjia-Bai commented 1 week ago

back-end development

Description

In this version, I solved the code conflict, but because a lot of code and files were added to upsteam/main, and I really couldn't merge this branch into the source branch of the previous pull request, I created this pull request and rewrite the documentation. You mentioned in the client meeting not to add other models, but I had already added the functions of PHS other than drawing before the meeting, so it is up to you to decide whether to delete it or not. I tried to implement other todo items, which mainly solved the problem of monitoring changes in input values.

Types of change

Implementation

Here I added PHS to the page. It and other models can change the input by directly modifying the value in the input box instead of only changing the input by clicking the button of the input box. image But because I did not add PHS-related plotting code, I will gain the error as shown in the figure.

First, I wanted to dynamically monitor changes in variable input, so I changed the id assigned when inputting parameters from static to dynamic, so that I can use ALL in Callback to input the parameters of all models. image

As shown below, in the Callback of the update_store_inputs functions, I use dynamic listening input changes instead of listening for form clicks and capturing the value entered in the form. 1725930937857

Since the values ​​captured from dynamic input is list rather than dictionary, they need to be processed into a dictionary named form_content as shown below before calling the get_inputs function in the update_chart function and the display_results function in the update_outputs function. image

The get_inputs function is also called in the display_results function. image

I did not use the find_dict_with_key_value function in the get_inputs function, but directly used form_content.get() to find the value corresponding to the key. The specific modifications are as follows: image

FedericoTartarini commented 1 week ago

There are a lot of confclicts that need to be solved and the title of the pull request is not clear.

Jinjia-Bai commented 1 week ago

I ran my branch after fixing the code conflict locally, there were three main types of errors:

  1. If the input Mean Radiation Temperature exceeds the value range or use a special value, an optimize.brentq() error will occur.
  2. There is no clothing input in Adaptive-ASHRAE 55, so an error will be reported once I selected this model.
  3. The PHS I added did not write any plotting-related code, so it also reported an error once I selected this model.