Edgar J. Kaiser
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月1日 GMT+1 08:13
Updated:
7 months ago
2024年2月1日 GMT+1 08:14
Hi Marianna,
I can't tell about the Matlab interface because I am not using it. You might consider to import the csv data directly into a 2D interpolation function in COMSOL and avoid the Matlab interfacing. This way you can call a function f(x, t) in the model. You have an interpolation in both dimensions, space and time.
Check the documentation about input formats of interpolation functions and about the way they interpolate to see if it is suitable for your project.
Cheers
Edgar
-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi Marianna, I can't tell about the Matlab interface because I am not using it. You might consider to import the csv data directly into a 2D interpolation function in COMSOL and avoid the Matlab interfacing. This way you can call a function f(x, t) in the model. You have an interpolation in both dimensions, space and time. Check the documentation about input formats of interpolation functions and about the way they interpolate to see if it is suitable for your project. Cheers Edgar
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月1日 GMT+1 09:52
Hi Edgar, many thanks for you suggest!
I have done some test but I didn't understand how I have to define my data. As I have read it's not possible used a grid with more 3 rows, is it correct? I have a file excel defined as in photo in which the yellow cells are the x coordinates and the rows from 2 to 6 are the number of timestep i.e. 1s, 2s, 3s...
How can I define a f(x,t) function in Comsol with my data?
Thank you in advance for your help! Marianna
Hi Edgar, many thanks for you suggest! I have done some test but I didn't understand how I have to define my data. As I have read it's not possible used a grid with more 3 rows, is it correct? I have a file excel defined as in photo in which the yellow cells are the x coordinates and the rows from 2 to 6 are the number of timestep i.e. 1s, 2s, 3s... How can I define a f(x,t) function in Comsol with my data? Thank you in advance for your help! Marianna
Edgar J. Kaiser
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月1日 GMT+1 18:47
Hi Marianna,
in the lines below the %Grid line you specify the nodes of your function, i.e the x and y values, or x and t in your case. So the first line would contain all the x values in the yellow line. The second line contains the t values, e.g. 1, 2, 3, etc. You don't need a third line because you only have two arguments in the function.
Below the %Data line you specify all the data values f(x, t) for the nodes in your function. Those are all the values in the white lines in your Excel sheet. They do not need to be structured in lines. This will be done according to the data under %Grid.
Cheers,
Edgar
-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi Marianna, in the lines below the %Grid line you specify the nodes of your function, i.e the x and y values, or x and t in your case. So the first line would contain all the x values in the yellow line. The second line contains the t values, e.g. 1, 2, 3, etc. You don't need a third line because you only have two arguments in the function. Below the %Data line you specify all the data values f(x, t) for the nodes in your function. Those are all the values in the white lines in your Excel sheet. They do not need to be structured in lines. This will be done according to the data under %Grid. Cheers, Edgar
Jeff Hiller
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月1日 GMT+1 19:39
Updated:
7 months ago
2024年2月1日 GMT+1 19:28
Hello Marianna,
Please review the section on interpolation functions in the COMSOL Multiphysics v6.2 Reference Manual, starting on page 362. In particular it contains, at the top of page 364, an example of what the data file should look like for a function of two arguments. All manuals are available in the GUI via the File > Help > Documentation menu.
Best,
Jeff
-------------------
Jeff Hiller
Hello Marianna, Please review the section on interpolation functions in the COMSOL Multiphysics v6.2 Reference Manual, starting on page 362. In particular it contains, at the top of page 364, an example of what the data file should look like for a function of two arguments. All manuals are available in the GUI via the File > Help > Documentation menu. Best, Jeff
Edgar J. Kaiser
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月1日 GMT+1 22:06
I understood that Marianna is intending to import a grid format, while the example on top of page 364 is a table. The grid format is shown on page 365 and unfortunately there is no example with numbers. I remember that it took me a little trial and error before I successfully imported a 3D grid a few years ago.
-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
I understood that Marianna is intending to import a grid format, while the example on top of page 364 is a table. The grid format is shown on page 365 and unfortunately there is no example with numbers. I remember that it took me a little trial and error before I successfully imported a 3D grid a few years ago.
Magnus Ringh
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月2日 GMT+1 12:16
Hi all,
Point taken: An example with numbers will be added to the documentation for the next version of COMSOL Multiphysics. Some aspects that also could be clarified: The rows with coordinates for thex,y, andzgrid coordinate values (for 3D), under %Grid, should only include the unique values for each coordinate direction and do not have to have the same length (say 10xvalues and 6yvalues for a 10-by-6 2D grid). The data values, under %Data, should then contain 6 rows with 10 values in each, representing the data values for grid points along thexdirection for all 6yvalues with oneyvalue for each row. In 3D, you would have to repeat the data in blocks with theyvalues repeated for eachzvalue to give you at total of (number ofyvalues) x (number ofzvalues) rows.
Best regards, Magnus
Hi all, Point taken: An example with numbers will be added to the documentation for the next version of COMSOL Multiphysics. Some aspects that also could be clarified: The rows with coordinates for the *x*, *y*, and *z* grid coordinate values (for 3D), under %Grid, should only include the unique values for each coordinate direction and do not have to have the same length (say 10 *x* values and 6 *y* values for a 10-by-6 2D grid). The data values, under %Data, should then contain 6 rows with 10 values in each, representing the data values for grid points along the *x* direction for all 6 *y* values with one *y* value for each row. In 3D, you would have to repeat the data in blocks with the *y* values repeated for each *z* value to give you at total of (number of *y* values) x (number of *z* values) rows. Best regards, Magnus
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月2日 GMT+1 16:43
Hi everyone, first of all thank you for helping me!
I finally fixed this problem and got the graph shown in the photos which is exactly what I expected.
Now I have another problem related to simulation convergence. I imposed the function int1(x,t) in the magnetic field-point constraint section as mf. By-(int1(x,t)) and I've tried changing some solver settings but it doesn't work.
Do you have any suggestions?
Hi everyone, first of all thank you for helping me! I finally fixed this problem and got the graph shown in the photos which is exactly what I expected. Now I have another problem related to simulation convergence. I imposed the function int1(x,t) in the magnetic field-point constraint section as mf. By-(int1(x,t)) and I've tried changing some solver settings but it doesn't work. Do you have any suggestions?
Edgar J. Kaiser
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月2日 GMT+1 19:15
Hi Marianna,
First: I think you have an issue with units and the location of the int1 function. The function is set up with mm and Comsol expects m in the constraint.
Second: The x-axis is ranging 0 ... 100 mm, while your line in the geometry is located -50 ... +50 mm. I changed the constraint expression to: mf.By-(int1(0.001*x+0.05,t)) It may be better to set up the input data in a way that fits the geometry.
Third: In the time dependent solver it is advisable to choose manual time stepping to make sure the solver properly samples the function in the temporal axis. I changed the time stepping to 'Generalized Alpha' with manual stepping and a time step of 1/(f*100). You can check if a larger time step still gives good results.
Fourth: I think the mesh on the constrained lines is not fine enough to properly sample the spatial dimension of the constraint. I changed it to equidistant distribution with 1000 elements. Maybe less works as well.
The model solves with those changes, and you will see if the results match your expectations.
Cheers Edgar
-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Hi Marianna, First: I think you have an issue with units and the location of the int1 function. The function is set up with mm and Comsol expects m in the constraint. Second: The x-axis is ranging 0 ... 100 mm, while your line in the geometry is located -50 ... +50 mm. I changed the constraint expression to: mf.By-(int1(0.001*x+0.05,t)) It may be better to set up the input data in a way that fits the geometry. Third: In the time dependent solver it is advisable to choose manual time stepping to make sure the solver properly samples the function in the temporal axis. I changed the time stepping to 'Generalized Alpha' with manual stepping and a time step of 1/(f*100). You can check if a larger time step still gives good results. Fourth: I think the mesh on the constrained lines is not fine enough to properly sample the spatial dimension of the constraint. I changed it to equidistant distribution with 1000 elements. Maybe less works as well. The model solves with those changes, and you will see if the results match your expectations. Cheers Edgar
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月5日 GMT+1 11:11
Hi Edga, thanks for the suggestions. Some I was able to implement, others I didn't. By chance you would be able to share my model with these changes made.
Best, Marianna
Hi Edga, thanks for the suggestions. Some I was able to implement, others I didn't. By chance you would be able to share my model with these changes made. Best, Marianna
Edgar J. Kaiser
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月6日 GMT+1 18:11
Sorry, I didn't save the test model. Where are you having issues?
-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Sorry, I didn't save the test model. Where are you having issues?
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月6日 GMT+1 19:53
Hi Edgar,
I have a preoblem with this part:
*I changed the time stepping to 'Generalized Alpha' with manual stepping and a time step of 1/(f100). *
I didn't find the settingGeneralized Alpha.
Hi Edgar, I have a preoblem with this part: *I changed the time stepping to 'Generalized Alpha' with manual stepping and a time step of 1/(f100). * I didn't find the setting **Generalized Alpha**.
Edgar J. Kaiser
Certified Consultant
Please login with a confirmed email address before reporting spam
Posted:
7 months ago
2024年2月6日 GMT+1 20:29
Go down along the Solver Configurations to the Time Dependent Solver and expand the tab 'Time Stepping'. Change the Method from BDF to Generalized Alpha, the Steps taken by solver to Manual and the Time step to 1/(f*100).
This approach typically works well on periodic waveforms.
Good luck!
-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Go down along the Solver Configurations to the Time Dependent Solver and expand the tab 'Time Stepping'. Change the Method from BDF to Generalized Alpha, the Steps taken by solver to Manual and the Time step to 1/(f*100). This approach typically works well on periodic waveforms. Good luck!